[ 
http://issues.apache.org/jira/browse/XERCESC-1409?page=comments#action_63356 ]
     
James Berry commented on XERCESC-1409:
--------------------------------------

Yeah, that's precisely what I was thinking.

 - Use a stack based buffer of characters (once again, numbers are pretty easy 
to put reasonable limits on--as long as you check for them ;).

 - You can do a single pass through the string that will transcode anything in 
your domain. You could limit that to plain ASCII, or just to the characters 
needed for numbers. If you find something outside of that range, then you error 
out early.

 - You could do the decimal point normalization in the same pass, eliminating 
yet another library call and yet another pass through the string.

 - You could also cache the locale info at class construction time (I'm not 
sure if the use-case for this requires multiple calls into this per class 
instance)? If not, then factoring out the local stuff won't help.

So, together with your strlen reduction, you can eliminate at least two other 
passes through the string (though you're going to have to do one of them to do 
the el-cheapo-transcode), potentially another couple of library calls for 
(localeconf and strchr), at least a memory alloc and delete, and whatever huge 
amount of code the transcoder goes through. You'll end up with two passes 
through the string: one to do the transcode/normalization, and one that the 
clib routine does to do the conversion.

On the surface it sounds like a big win if these things are getting called 
frequently.

> More efficient error detection for XSValue, XMLDouble, and XMLFloat
> -------------------------------------------------------------------
>
>          Key: XERCESC-1409
>          URL: http://issues.apache.org/jira/browse/XERCESC-1409
>      Project: Xerces-C++
>         Type: Improvement
>   Components: Validating Parser (Schema) (Xerces 1.5 or up only)
>     Versions: 2.6.0
>     Reporter: David Bertoni
>     Assignee: David Bertoni
>  Attachments: patch.txt
>
> These classes check for invalid characters in numeric values by determining 
> if a C run-library routine reached the end of the string.  There is a more 
> efficient way to do this than what the current code does.
> I am attaching a patch.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to