|
From: Seth D. <set...@us...> - 2004-12-05 00:09:28
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20576 Modified Files: stringverbs.c Log Message: optimization - midfunc (ie string.mid) now uses a readonly handle for the input string, and copies only the results to the output string, for performance Index: stringverbs.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/stringverbs.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** stringverbs.c 28 Oct 2004 22:30:43 -0000 1.3 --- stringverbs.c 5 Dec 2004 00:09:15 -0000 1.4 *************** *** 1359,1362 **** --- 1359,1365 ---- 6.1d5 AR: added urlSplit, hasSuffix. string.dateString and string.timeString now optionally accept a date parameter. + + 12/4/2004 smd: optimization - midfunc (ie string.mid) now uses a readonly handle for + the input string, and copies only the results to the output string, for performance */ *************** *** 1533,1536 **** --- 1536,1542 ---- case midfunc: { + + /* 12/4/2004 smd: optimized */ + Handle hstring; Handle x; *************** *** 1538,1541 **** --- 1544,1548 ---- long len; + if (!getpositivelongvalue (hp1, 2, &ix)) return (false); *************** *** 1546,1569 **** return (false); ! if (!getexempttextvalue (hp1, 1, &hstring)) /*get last to simplify error handling*/ return (false); - x = hstring; /*copy into register*/ - if (ix > 0) --ix; /*convert to zero-base*/ ! len = min (len, gethandlesize (x) - ix); ! ! if ((len > 0) && (ix > 0)) ! moveleft (*x + ix, *x, len); ! ! sethandlesize (x, max (len, 0)); ! /* ! if (!loadfromhandletohandle (hstring, &ix, len, &x)) ! if (!newemptyhandle (&x)) ! return (false); ! */ return (setheapvalue (x, stringvaluetype, v)); --- 1553,1571 ---- return (false); ! if (!getreadonlytextvalue (hp1, 1, &hstring)) /*get last to simplify error handling*/ return (false); if (ix > 0) --ix; /*convert to zero-base*/ ! len = min (len, gethandlesize (hstring) - ix); ! if (len > 0) { ! if (!loadfromhandletohandle(hstring, &ix, len, false, &x)) ! if (!newemptyhandle (&x)) ! return (false); ! } ! else if (!newemptyhandle (&x)) ! return false; return (setheapvalue (x, stringvaluetype, v)); |