Poiché il quesito stati trovati il codice seguente:Java String.split passare in regex precompilata per performance ragiona
public class Foo
{
public static void main(String[] args)
{
String test = "Cats go meow";
String[] tokens = test.split(" ");
}
}
è possibile precompilare che regex in funzione split lungo le linee di questo:
public class Foo
{
Pattern pattern = Pattern.compile(" ");
public static void main(String[] args)
{
String test = "Cats go meow";
String[] tokens = test.split(pattern);
}
}
split (" ") è più veloce (vedi commento qui sotto) –
@michael_s ho aggiunto un commento, vi preghiamo di contrastare. – Woot4Moo