[cvsnt] PATCH - more readable RootOverlaps()

Alexey Panchenko alexey-panchenko at hotmail.ru
Wed Mar 2 05:28:58 GMT 2005


Community technical support mailing list was retired 2010 and replaced with a professional technical support team. For assistance please contact: Pre-sales Technical support via email to sales@march-hare.com.


Hello !

I think this implementation is more readable.

Index: LockParse.cpp
===================================================================
RCS file: /usr/local/cvs/cvsnt/lockservice/LockParse.cpp,v
retrieving revision 1.15
diff -u -r1.15 LockParse.cpp
--- LockParse.cpp       9 Feb 2005 15:30:47 -0000       1.15
+++ LockParse.cpp       2 Mar 2005 04:25:23 -0000
@@ -210,10 +210,8 @@
 
 bool RootOverlaps(size_t client, std::string& root1, std::string& root2)
 {
-       if(root1.length()>root2.length())
-               return LockClientMap[client].fnncmp(root1.c_str(),root2.c_str(),root2.length())?false:true;
-       else
-               return LockClientMap[client].fnncmp(root1.c_str(),root2.c_str(),root1.length())?false:true;
+       size_t minLength = min(root1.length(), root2.length());
+       return LockClientMap[client].fnncmp(root1.c_str(), root2.c_str(), minLength) ? false : true;
 }

 
-- 
Best regards,
 Alexey                          mailto:alexey-panchenko at hotmail.ru




More information about the cvsnt mailing list
Download the latest CVSNT, TortosieCVS, WinCVS etc. for Windows 8 etc.
@CVSNT on Twitter   CVSNT on Facebook