Using StringUtils methods faster than Java methods?

I want to know if a method from StringUtils from the Apache Commons Lang library is faster than Java String methods.

I know that this is micro-optimization, but it is necessary because the methods will be executed millions of times.

Methods that use regular expression in Java, for example, split()or string comparison with equals().

+5
source share
7 answers

StringUtils#splitfaster than String#split.

String#equalsfaster than StringUtils#equals.

+1
source

Java String StringUtils , . . , , , , , .

, , , ! .

, , , , .

+3

, , . , ,

return s1 == s2 || (s1 == null && s2 == null) || (s1 != null && s1.equals( s2 ) );

, , , hotspot . , , , .

, , , System.currentTimeMillis() , ; , , .

+1

, , Apache Commons " ", , .

JVM.

, . , - . , ( , , ..). JVM. " " , .

, , . , , , .

+1

-, ? ?

-, ? , , , .

, , . , , , . , String.equals - String. , equals true ==, . , , , , .

0

? ? , . , . " ?" , . , , , , .

0

. StringUtils String, . StringUtils String. , , .

0

All Articles