RFR: 8224202: Speed up Properties.load
Claes Redestad
claes.redestad at oracle.com
Wed May 22 22:19:35 UTC 2019
Hi Roger,
On 2019-05-22 20:09, Roger Riggs wrote:
> Hi Claes,
>
> Properties.java: 542-547, 636-639 you might find the function Ivan added
> useful:
> newlen = ArraySupport.newLength(oldlength, min, preferred);
good suggestion - this is a slow path that we don't hit in any of the
startup tests I'm concerned with, so let's use that.
>
> Can it be refactored differently to read the bytes into a char array and
> then process that to avoid the processing code duplication.
.. not without a slowdown.
>
> If not, can you put the two byte and char versions of readLine in
> separate methods,
> That massive if..else is ugly. Not sharing most of the code doing the
> same things is quite ugly too.
... let's take a step back from that particular ugliness. :-)
http://cr.openjdk.java.net/~redestad/8224202/open.02/
- Joined stream/reader code paths back together
- Consume comment lines completely - reading new data from
stream/reader if we need to - removes the need for the
isCommentLine control variable
- Realized isNewLine is true iff len == 0, so it can be removed
This ends up being almost exactly as fast as open.01, with much
less code duplication. The break-to-label is unfortunate, of course.
/Claes
More information about the core-libs-dev
mailing list