|
From: Seth D. <set...@us...> - 2004-12-06 00:51:24
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26441 Modified Files: stringverbs.c Log Message: optimization - grabnthfield() now takes an additional parameter, Handle *hfield, where the extracted field will be stored. After calling textnthword() to find the field, it uses loadfromhandletohandle to create handle at *hfield and fill it with the result value. grabnthfield is only used in stringverbs.c, and all callers have been updated to provide the extra param. Also, nthfieldfunc, firstwordfunc, and nthwordfunc now declare the extra handle, and use getreadonlytextvalue instead of getextempttextvalue. Wow, I need to write shorter notes. Index: stringverbs.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/stringverbs.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** stringverbs.c 5 Dec 2004 22:08:23 -0000 1.5 --- stringverbs.c 6 Dec 2004 00:51:12 -0000 1.6 *************** *** 1031,1036 **** ! static void grabnthfield (Handle htext, long fieldnum, byte chdelim, boolean flstrict) { ! long ixword, lenword; --- 1031,1039 ---- ! static void grabnthfield (Handle htext, long fieldnum, byte chdelim, Handle *hfield, boolean flstrict) { ! ! /* 12/5/2004 smd: optimization - now takes hfield parameter, a pointer to the ! handle for the extracted field */ ! long ixword, lenword; *************** *** 1038,1045 **** lenword = 0; ! if ((lenword > 0) && (ixword > 0)) ! moveleft (*htext + ixword, *htext, lenword); - sethandlesize (htext, lenword); } /*grabnthfield*/ --- 1041,1047 ---- lenword = 0; ! if (!loadfromhandletohandle (htext, &ixword, lenword, false, hfield)) ! newemptyhandle (hfield); } /*grabnthfield*/ *************** *** 1592,1596 **** if (len > 0) { ! if (!loadfromhandletohandle(hstring, &ix, len, false, &x)) if (!newemptyhandle (&x)) return (false); --- 1594,1598 ---- if (len > 0) { ! if (!loadfromhandletohandle (hstring, &ix, len, false, &x)) if (!newemptyhandle (&x)) return (false); *************** *** 1625,1628 **** --- 1627,1631 ---- case nthfieldfunc: { Handle htext; + Handle x; char chdelim; long fieldnum; *************** *** 1643,1652 **** } /*if*/ ! if (!getexempttextvalue (hp1, 1, &htext)) /*get last to simplify error handing*/ return (false); ! grabnthfield (htext, fieldnum, chdelim, true); ! return (setheapvalue (htext, stringvaluetype, v)); } --- 1646,1655 ---- } /*if*/ ! if (!getreadonlytextvalue (hp1, 1, &htext)) /*get last to simplify error handing*/ return (false); ! grabnthfield (htext, fieldnum, chdelim, &x, true); ! return (setheapvalue (x, stringvaluetype, v)); } *************** *** 1673,1685 **** case firstwordfunc: { Handle htext; flnextparamislast = true; ! if (!getexempttextvalue (hp1, 1, &htext)) /*get last to simplify error handing*/ return (false); ! grabnthfield (htext, 1, chword, false); ! return (setheapvalue (htext, stringvaluetype, v)); } --- 1676,1689 ---- case firstwordfunc: { Handle htext; + Handle x; flnextparamislast = true; ! if (!getreadonlytextvalue (hp1, 1, &htext)) /*get last to simplify error handing*/ return (false); ! grabnthfield (htext, 1, chword, &x, false); ! return (setheapvalue (x, stringvaluetype, v)); } *************** *** 1699,1702 **** --- 1703,1707 ---- case nthwordfunc: { Handle htext; + Handle x; long wordnum; *************** *** 1706,1715 **** return (false); ! if (!getexempttextvalue (hp1, 1, &htext)) /*get last to simplify error handing*/ return (false); ! grabnthfield (htext, wordnum, chword, false); ! return (setheapvalue (htext, stringvaluetype, v)); } --- 1711,1720 ---- return (false); ! if (!getreadonlytextvalue (hp1, 1, &htext)) /*get last to simplify error handing*/ return (false); ! grabnthfield (htext, wordnum, chword, &x, false); ! return (setheapvalue (x, stringvaluetype, v)); } |