[OPEN-ILS-DEV] PATCH: apachetools.c (performance)
Scott McKellar
mck9 at swbell.net
Tue May 13 23:54:50 EDT 2008
This patch is mostly a performance tweak, but also tidies up a few
things.
In apacheParseParms() we load POST data and GET data into the same
buffer, with the GET data coming first. However the old code loads
the POST data first. If there is also some GET data, we juggle some
buffers in order to get the GET and POST data into the right order.
The new code loads the GET data first, and then appends the POST
data onto it. Besides being simpler, the new code avoids a layer
of copying, as well as and two round trips through malloc() and
free().
Other details:
1. I rearranged the declarations of the variables sarray, buffer,
key, and val, so as to narrow their scope. In the case of sarray
this rearrangement avoids a potential memory leak in the case of an
error exit (where the POST data is excessive).
2. I append a terminal null to the input buffer instead of using
memset() to fill the entire buffer.
3. Since the bread variable is a long rather than an int, I corrected
the format specifier accordingly in one of the debug messages.
4. I eliminated some redundant casts in a couple of calls to
ap_unescape(), since the variables so cast are already the right
types.
5. The final debug message was being issued only when sarray was
not NULL. However at this spot sarray cannot be NULL anyway, so I
eliminated the test of sarray.
-----------
The new version appeared to behave identically to the old. However
my testing was necessarily somewhat artificial. Perhaps you can
devise a more realistic test involving both POST and GET data.
Scott McKellar
http://home.swbell.net/mck9/ct/
Developer's Certificate of Origin 1.1 By making a contribution to
this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license indicated
in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source license
and I have the right under that license to submit that work with
modifications, whether created in whole or in part by me, under the
same open source license (unless I am permitted to submit under a
different license), as indicated in the file; or
(c) The contribution was provided directly to me by some other person
who certified (a), (b) or (c) and I have not modified it; and
(d) In the case of each of (a), (b), or (c), I understand and agree
that this project and the contribution are public and that a record
of the contribution (including all personal information I submit
with it, including my sign-off) is maintained indefinitely and may
be redistributed consistent with this project or the open source
license indicated in the file.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: apachetools_c_2.patch
Type: text/x-patch
Size: 4988 bytes
Desc: 1068406917-apachetools_c_2.patch
Url : http://list.georgialibraries.org/pipermail/open-ils-dev/attachments/20080513/360a2de2/apachetools_c_2.bin
More information about the Open-ils-dev
mailing list