abrensch / brouter

configurable OSM offline router with elevation awareness, Java + Android
MIT License
494 stars 118 forks source link

Replace multiple occurrences of toLowerCase() #616

Closed moving-bits closed 1 year ago

moving-bits commented 1 year ago

Avoids recalculation of toLowerCase() for every branch in addLookupValue()

afischerdev commented 1 year ago

Thank you for contributing

quaelnix commented 1 year ago

Thank you for contributing

Yes, but does this really improve the performance (and or readability) of the code?

moving-bits commented 1 year ago

Thank you for contributing

Yes, but does this really improve the performance (and or readability) of the code?

Readability IMHO yes (but that's partly a matter of personal preference), and performance depends on which switch branch gets called.

afischerdev commented 1 year ago

From my point of view I can't see much more readability here valueLowerCase vs value.toLowerCase. The benefit I see is the single call of the function. And may be an other one for the call with Locale.US - when this is using an ASCII and not an UTF16 variant.

But the longer I look at this code, I see another optimization:

I'll do that the next days.