Alan, Sorry I should've stated that I looked at this in detail in java 6 but only glanced at the UUID impl in 7 just now on my phone. If String.split() has a fast path now then forget my suggestion #1 :). Using Long.parseLong should still be applicable though.
Thanks Sent from my phone On Feb 28, 2012 9:37 AM, "Alan Bateman" <[email protected]> wrote: > On 28/02/2012 14:26, Vitaly Davidovich wrote: > >> Hi all, >> >> I noticed that this method could be made a bit more performant by: >> >> 1) creating a statically initialized Pattern for "-" and then calling >> split() on that. Currently the method calls name.split() which compiles >> the pattern on each invocation. >> >> 2) use Long.parseLong() instead of Long.decode() to extract the bits. >> >> With these changes, the method runs at least 20% faster (some runs were >> significantly faster) on an Intel Westmere server and should be a bit more >> GC friendly. >> >> Any thoughts? I can send the full code a bit later when I'm in front of my >> computer. >> >> Thanks >> >> Sent from my phone >> > Just on name.split, are you sure this is compiling a pattern each time? > There is a fast path in String.split since jdk7 for the common case so I > would not expect the regex code to be used. > > -Alan. >
