@@ -1804,15 +1804,15 @@ protected Object lstripBangSingleByte(RubyString string,
1804
1804
// Check the first code point to see if it's a space. In the case of strings without leading spaces,
1805
1805
// this check can avoid having to materialize the entire byte[] (a potentially expensive operation
1806
1806
// for ropes) and can avoid having to compile the while loop.
1807
- if (noopProfile .profile (!isSpace (firstCodePoint ))) {
1807
+ if (noopProfile .profile (!StringSupport . isAsciiSpaceOrNull (firstCodePoint ))) {
1808
1808
return nil ;
1809
1809
}
1810
1810
1811
1811
final int end = rope .byteLength ();
1812
1812
final byte [] bytes = bytesNode .execute (rope );
1813
1813
1814
1814
int p = 0 ;
1815
- while (p < end && isSpace (bytes [p ])) {
1815
+ while (p < end && StringSupport . isAsciiSpaceOrNull (bytes [p ])) {
1816
1816
p ++;
1817
1817
}
1818
1818
@@ -1838,7 +1838,7 @@ protected Object lstripBang(RubyString string,
1838
1838
int p = s ;
1839
1839
while (p < end ) {
1840
1840
int c = getCodePointNode .executeGetCodePoint (enc , rope , p );
1841
- if (!( c == 0 || ASCIIEncoding . INSTANCE . isSpace ( c ) )) {
1841
+ if (!StringSupport . isAsciiSpaceOrNull ( c )) {
1842
1842
break ;
1843
1843
}
1844
1844
p += StringSupport .codeLength (enc .jcoding , c );
@@ -1853,9 +1853,6 @@ protected Object lstripBang(RubyString string,
1853
1853
return nil ;
1854
1854
}
1855
1855
1856
- private boolean isSpace (int c ) {
1857
- return c == 0 || StringSupport .isAsciiSpace (c );
1858
- }
1859
1856
}
1860
1857
1861
1858
@ CoreMethod (names = "ord" )
@@ -1935,7 +1932,7 @@ protected Object rstripBangSingleByte(RubyString string,
1935
1932
// Check the last code point to see if it's a space or NULL. In the case of strings without leading spaces,
1936
1933
// this check can avoid having to materialize the entire byte[] (a potentially expensive operation
1937
1934
// for ropes) and can avoid having to compile the while loop.
1938
- final boolean willStrip = lastCodePoint == 0x00 || StringSupport .isAsciiSpace (lastCodePoint );
1935
+ final boolean willStrip = StringSupport .isAsciiSpaceOrNull (lastCodePoint );
1939
1936
if (noopProfile .profile (!willStrip )) {
1940
1937
return nil ;
1941
1938
}
@@ -1944,7 +1941,7 @@ protected Object rstripBangSingleByte(RubyString string,
1944
1941
final byte [] bytes = bytesNode .execute (rope );
1945
1942
1946
1943
int endp = end - 1 ;
1947
- while (endp >= 0 && ( bytes [ endp ] == 0 || StringSupport .isAsciiSpace (bytes [endp ]) )) {
1944
+ while (endp >= 0 && StringSupport .isAsciiSpaceOrNull (bytes [endp ])) {
1948
1945
endp --;
1949
1946
}
1950
1947
@@ -1979,7 +1976,7 @@ protected Object rstripBang(RubyString string,
1979
1976
int prev ;
1980
1977
while ((prev = prevCharHead (enc .jcoding , bytes , start , endp , end )) != -1 ) {
1981
1978
int point = getCodePointNode .executeGetCodePoint (enc , rope , prev );
1982
- if (point != 0 && ! ASCIIEncoding . INSTANCE . isSpace (point )) {
1979
+ if (! StringSupport . isAsciiSpaceOrNull (point )) {
1983
1980
break ;
1984
1981
}
1985
1982
endp = prev ;
0 commit comments