harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Ellison (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-6635) FloatingPointParser uses toLowerCase unnecessarily
Date Tue, 21 Sep 2010 22:21:34 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-6635?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Tim Ellison updated HARMONY-6635:
---------------------------------

    Attachment: harmony-6635.patch

I agree -- and the use of "indexOf" to search the entire string looks strange too.

It's a bit more complex than you suggest (but not much more), since there is an optional sign
indicator.  Patch attached.

I wrote a simple benchmark with the toLowerCase/indexOf compared to a direct check, and there
isn't too much in it..

--
Parse "0x1.P1" and "0x113D4cc.P22" about 40k times

Current code, runs (ms) =  2157, 2125, 2032, 2204, 2141
New code, runs (ms) = 1843, 1984, 2032, 1953
--

Do you have some benchmark or application you can try that might shows the difference more
starkly?


> FloatingPointParser uses toLowerCase unnecessarily
> --------------------------------------------------
>
>                 Key: HARMONY-6635
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6635
>             Project: Harmony
>          Issue Type: Improvement
>         Environment: Android 2.2
>            Reporter: Gaz Davidson
>         Attachments: harmony-6635.patch
>
>
> A lot of time is being eaten inside FloatingPointParser.java calling String.toLowerCase
when testing for "hex float" types.
> > if (s.toLowerCase().indexOf("0x") != -1) 
> I imagine that such hex float numbers are very rare, so this is a huge waste of time
in the general case.
> I haven't tested this, but it looks to me like the string is already trimmed and so checking
at a specific location should speed this up considerably:
> > if (s.size() > 2 && s.charAt(0) =='0' && (s.charAt(1) == 'x'
|| s.charAt(1) == 'X')) 

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


Mime
View raw message