PeformanceTip: Pre-compile your patterns


Building/compiling a regular expression can be expensive and is done at runtime. This can be avoided by pre-compiling the pattern.

Save the pattern in a CONSTANT

From UUID.fromString(String)
String[] components = name.split("-");
can be replaced with
public static final Pattern HYPHEN_PATTERN = Pattern.compile("-");

String[] components = HYPHEN_PATTERN.split(name, 0);


Popular posts from this blog

Java is Very Fast, If You Don’t Create Many Objects

System wide unique nanosecond timestamps

Comparing Approaches to Durability in Low Latency Messaging Queues