[ 
https://issues.apache.org/jira/browse/VFS-160?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12495732
 ] 

Adam Heath commented on VFS-160:
--------------------------------

Method call overhead showed up in a profiling run, in high-volume repeated 
calls.  It's not enough to compare *just* this method, but when you have 
several layered files, and the name is parsed at each level, the overhead does 
add up.

It's the chained methods(super.encodeCharacter), and the chained comparisons, 
in the worst case, that show the slowdown.  When a character doesn't need to be 
encoded, the parents are all called, and each comparison in each child then has 
to fail, before it finally returns.

The patch reduces all that to a single array index, then a call to the BitSet.  
The time is now constant, no matter how many characters have to be encoded.  
Before, the time was not constant, as some characters would take longer to 
check whether they needed to be encoded, because more super.encodeCharacter 
calls would be invoked.

> Speedup FileNameParser.encodeCharacter
> --------------------------------------
>
>                 Key: VFS-160
>                 URL: https://issues.apache.org/jira/browse/VFS-160
>             Project: Commons VFS
>          Issue Type: Improvement
>    Affects Versions: 1.1
>            Reporter: Adam Heath
>            Priority: Minor
>         Attachments: feature_array-based-encodeCharacter.patch
>
>
> Use an array for characters < 256, and a BitSet for those larger.  Speedup 
> improvement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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

Reply via email to