hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roland Weber (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HTTPCORE-122) new interface TokenIterator
Date Sun, 02 Dec 2007 08:34:43 GMT

    [ https://issues.apache.org/jira/browse/HTTPCORE-122?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12547594
] 

Roland Weber commented on HTTPCORE-122:
---------------------------------------

Hi Oleg,

whether there is an underlying CharArrayBuffer or not depends on the kind of header one iterates
over. Conversion is needed in one way or another, String to CAB or vice versa.
For the HeaderElementIterator, parsing is delegated to the parser framework, which internally
uses CAB. It therefore makes sense to do the conversion in that direction. Otherwise, headers
with an underlying CAB would be converted to String and back to a new CAB. I don't see a similar
advantage for the BasicTokenIterator, which parses the strings directly. There is no continuation
line joining when splitting header values.
The output of the TokenIterator are strings. IIRC, the implementation of java.lang.String.substring
is optimized and reuses the char array of the original string, while conversion from CAB to
String requires copying of the substring characters. All in all, I don't see what would be
gained from using CAB in the BasicTokenIterator.
If you prefer that, I can rewrite the code to use CAB next weekend. In general, I don't expect
a penalty. In most situations, the header will be that of a received message and therefore
have a CAB. Converting substrings to String for each token will hardly be cheaper or more
expensive than converting the whole header value once.

When we upgrade the JDK requirement for HttpCore 4.1, we can rewrite much of the parsing code
to use java.lang.CharSequence and avoid the conversions altogether. Too bad they didn't have
that idea for Java 1.3.

cheers,
  Roland


> new interface TokenIterator
> ---------------------------
>
>                 Key: HTTPCORE-122
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-122
>             Project: HttpComponents Core
>          Issue Type: Sub-task
>          Components: HttpCore
>    Affects Versions: 4.0-alpha5
>            Reporter: Roland Weber
>            Assignee: Roland Weber
>            Priority: Minor
>             Fix For: 4.0-beta1
>
>         Attachments: 2k7-11-30-token-iter.txt
>
>
> As discussed for HTTPCORE-112, a new interface and implementation for iterating over
String tokens in a header value would be useful.
> The implementation can be based on the HeaderIterator introduced with HTTPCORE-120.

-- 
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: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


Mime
View raw message