[sword-cvs] sword/src/utilfuns swbuf.cpp,1.17,1.18

sword@www.crosswire.org sword@www.crosswire.org
Thu, 15 Apr 2004 07:39:15 -0700


Update of /cvs/core/sword/src/utilfuns
In directory www:/tmp/cvs-serv21353/src/utilfuns

Modified Files:
	swbuf.cpp 
Log Message:
mgruner: make this a little more speedy, instead 
	of calling strlen() 3 times in worst case.


Index: swbuf.cpp
===================================================================
RCS file: /cvs/core/sword/src/utilfuns/swbuf.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- swbuf.cpp	15 Apr 2004 11:17:52 -0000	1.17
+++ swbuf.cpp	15 Apr 2004 14:39:12 -0000	1.18
@@ -141,7 +141,8 @@
 */
 void SWBuf::append(const char *str, const long max) {
 	//make sure we only copy strlen(str) bytes if max is larger than strlen(str) is
-	unsigned long len = (max > -1) ? ((max <= strlen(str)) ? max : strlen(str)) : strlen(str);
+	unsigned long str_len = strlen( str );
+	unsigned long len = (max > -1) ? ((max <= str_len) ? max : str_len) : str_len;
 	assureMore(++len);
 	memcpy(end, str, len-1);
 	end += (len-1);