Skip to main content
replaced http://bugs.sun.com/view_bug.do with https://bugs.java.com/bugdatabase/view_bug
Source Link

String.split(String) won't create regexp if your pattern is only one character long. When splitting by single character, it will use specialized code which is pretty efficient. StringTokenizer is not much faster in this particular case.

This was introduced in OpenJDK7/OracleJDK7. Here's a bug reportHere's a bug report and a commit. I've made a simple benchmark here.


$ java -version java version "1.8.0_20" Java(TM) SE Runtime Environment (build 1.8.0_20-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode) $ java Split split_banthar: 1231 split_tskuzzy: 1464 split_tskuzzy2: 1742 string.split: 1291 StringTokenizer: 1517 

String.split(String) won't create regexp if your pattern is only one character long. When splitting by single character, it will use specialized code which is pretty efficient. StringTokenizer is not much faster in this particular case.

This was introduced in OpenJDK7/OracleJDK7. Here's a bug report and a commit. I've made a simple benchmark here.


$ java -version java version "1.8.0_20" Java(TM) SE Runtime Environment (build 1.8.0_20-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode) $ java Split split_banthar: 1231 split_tskuzzy: 1464 split_tskuzzy2: 1742 string.split: 1291 StringTokenizer: 1517 

String.split(String) won't create regexp if your pattern is only one character long. When splitting by single character, it will use specialized code which is pretty efficient. StringTokenizer is not much faster in this particular case.

This was introduced in OpenJDK7/OracleJDK7. Here's a bug report and a commit. I've made a simple benchmark here.


$ java -version java version "1.8.0_20" Java(TM) SE Runtime Environment (build 1.8.0_20-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode) $ java Split split_banthar: 1231 split_tskuzzy: 1464 split_tskuzzy2: 1742 string.split: 1291 StringTokenizer: 1517 
deleted 90 characters in body
Source Link
Piotr Praszmo
  • 18.4k
  • 2
  • 59
  • 66

String.split(String) won't create regexp if your pattern is only one character long. When splitting by single character, it will use specialized code which is pretty efficient. StringTokenizer is not much faster in this particular case.

This was introduced in OpenJDK7/OracleJDK7. Here's a bug report and a commit. This wasn't that long ago so it won't affect you, if you are using older versions (probably anything other than oracle7 or openjdk7). I've made a simple benchmark here.


$ java -version java version "1.8.0_20" Java(TM) SE Runtime Environment (build 1.8.0_20-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode) $ java Split split_banthar: 1231 split_tskuzzy: 1464 split_tskuzzy2: 1742 string.split: 1291 StringTokenizer: 1517 

String.split(String) won't create regexp if your pattern is only one character long. When splitting by single character, it will use specialized code which is pretty efficient. StringTokenizer is not much faster in this particular case.

Here's a bug report and a commit. This wasn't that long ago so it won't affect you, if you are using older versions (probably anything other than oracle7 or openjdk7). I've made a simple benchmark here.


$ java -version java version "1.8.0_20" Java(TM) SE Runtime Environment (build 1.8.0_20-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode) $ java Split split_banthar: 1231 split_tskuzzy: 1464 split_tskuzzy2: 1742 string.split: 1291 StringTokenizer: 1517 

String.split(String) won't create regexp if your pattern is only one character long. When splitting by single character, it will use specialized code which is pretty efficient. StringTokenizer is not much faster in this particular case.

This was introduced in OpenJDK7/OracleJDK7. Here's a bug report and a commit. I've made a simple benchmark here.


$ java -version java version "1.8.0_20" Java(TM) SE Runtime Environment (build 1.8.0_20-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode) $ java Split split_banthar: 1231 split_tskuzzy: 1464 split_tskuzzy2: 1742 string.split: 1291 StringTokenizer: 1517 
added 341 characters in body
Source Link
Dave Jarvis
  • 31.3k
  • 43
  • 186
  • 326

String.split(String) won't create regexp if your pattern is only one character long. When splitting by single character, it will use specialized code which is pretty efficient. StringTokenizer is not much faster in this particular case.

Here's a bug report and a commit. This wasn't that long ago so it won't affect you, if you are using older versions (probably anything other than oracle7 or openjdk7). I've made a simple benchmark here.


$ java -version java version "1.8.0_20" Java(TM) SE Runtime Environment (build 1.8.0_20-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode) $ java Split split_banthar: 1231 split_tskuzzy: 1464 split_tskuzzy2: 1742 string.split: 1291 StringTokenizer: 1517 

String.split(String) won't create regexp if your pattern is only one character long. When splitting by single character, it will use specialized code which is pretty efficient. StringTokenizer is not much faster in this particular case.

Here's a bug report and a commit. This wasn't that long ago so it won't affect you, if you are using older versions (probably anything other than oracle7 or openjdk7). I've made a simple benchmark here.

String.split(String) won't create regexp if your pattern is only one character long. When splitting by single character, it will use specialized code which is pretty efficient. StringTokenizer is not much faster in this particular case.

Here's a bug report and a commit. This wasn't that long ago so it won't affect you, if you are using older versions (probably anything other than oracle7 or openjdk7). I've made a simple benchmark here.


$ java -version java version "1.8.0_20" Java(TM) SE Runtime Environment (build 1.8.0_20-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode) $ java Split split_banthar: 1231 split_tskuzzy: 1464 split_tskuzzy2: 1742 string.split: 1291 StringTokenizer: 1517 
added 352 characters in body
Source Link
Piotr Praszmo
  • 18.4k
  • 2
  • 59
  • 66
Loading
Source Link
Piotr Praszmo
  • 18.4k
  • 2
  • 59
  • 66
Loading