File tree Expand file tree Collapse file tree
core/src/main/java/org/elasticsearch/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -534,29 +534,25 @@ public static Set<String> splitStringToSet(final String s, final char c) {
534534 final int len = chars .length ;
535535 int start = 0 ; // starting index in chars of the current substring.
536536 int pos = 0 ; // current index in chars.
537- int whitespaceStart = - 1 ; // the position of the start of the current whitespace, -1 if not on whitespace
537+ int end = 0 ; // the position of the end of the current token
538538 for (; pos < len ; pos ++) {
539539 if (chars [pos ] == c ) {
540- int size = ( whitespaceStart < 0 ? pos : whitespaceStart ) - start ;
540+ int size = end - start ;
541541 if (size > 0 ) { // only add non empty strings
542542 result .add (new String (chars , start , size ));
543543 }
544544 start = pos + 1 ;
545- whitespaceStart = - 1 ;
545+ end = start ;
546546 } else if (Character .isWhitespace (chars [pos ])) {
547547 if (start == pos ) {
548548 // skip over preceding whitespace
549549 start ++;
550- } else if (whitespaceStart < 0 ) {
551- // start of whitespace
552- whitespaceStart = pos ;
553550 }
554551 } else {
555- // reset whitespace position
556- whitespaceStart = -1 ;
552+ end = pos + 1 ;
557553 }
558554 }
559- int size = ( whitespaceStart < 0 ? pos : whitespaceStart ) - start ;
555+ int size = end - start ;
560556 if (size > 0 ) {
561557 result .add (new String (chars , start , size ));
562558 }
You can’t perform that action at this time.
0 commit comments