@@ -1680,10 +1680,12 @@ static boolean doString(String self) {
1680
1680
if (self .length () == 0 ) {
1681
1681
return false ;
1682
1682
}
1683
- for (int i = 0 ; i < self .length (); i ++) {
1684
- if (!Character .isLetterOrDigit (self .codePointAt (i ))) {
1683
+ for (int i = 0 ; i < self .length ();) {
1684
+ int codePoint = self .codePointAt (i );
1685
+ if (!Character .isLetterOrDigit (codePoint )) {
1685
1686
return false ;
1686
1687
}
1688
+ i += Character .charCount (codePoint );
1687
1689
}
1688
1690
return true ;
1689
1691
}
@@ -1704,10 +1706,12 @@ static boolean doString(String self) {
1704
1706
if (self .length () == 0 ) {
1705
1707
return false ;
1706
1708
}
1707
- for (int i = 0 ; i < self .length (); i ++) {
1708
- if (!Character .isLetter (self .codePointAt (i ))) {
1709
+ for (int i = 0 ; i < self .length ();) {
1710
+ int codePoint = self .codePointAt (i );
1711
+ if (!Character .isLetter (codePoint )) {
1709
1712
return false ;
1710
1713
}
1714
+ i += Character .charCount (codePoint );
1711
1715
}
1712
1716
return true ;
1713
1717
}
@@ -1728,10 +1732,12 @@ static boolean doString(String self) {
1728
1732
if (self .length () == 0 ) {
1729
1733
return false ;
1730
1734
}
1731
- for (int i = 0 ; i < self .length (); i ++) {
1732
- if (!Character .isDigit (self .codePointAt (i ))) {
1735
+ for (int i = 0 ; i < self .length ();) {
1736
+ int codePoint = self .codePointAt (i );
1737
+ if (!Character .isDigit (codePoint )) {
1733
1738
return false ;
1734
1739
}
1740
+ i += Character .charCount (codePoint );
1735
1741
}
1736
1742
return true ;
1737
1743
}
@@ -1778,7 +1784,7 @@ static boolean doString(String self) {
1778
1784
if (self .length () == 0 ) {
1779
1785
return false ;
1780
1786
}
1781
- for (int i = 0 ; i < self .length (); i ++ ) {
1787
+ for (int i = 0 ; i < self .length ();) {
1782
1788
int codePoint = self .codePointAt (i );
1783
1789
if (!Character .isLowerCase (codePoint )) {
1784
1790
if (Character .toLowerCase (codePoint ) == Character .toUpperCase (codePoint )) {
@@ -1787,6 +1793,7 @@ static boolean doString(String self) {
1787
1793
return false ;
1788
1794
}
1789
1795
}
1796
+ i += Character .charCount (codePoint );
1790
1797
}
1791
1798
return uncased == 0 || self .length () > uncased ;
1792
1799
}
@@ -1813,10 +1820,12 @@ private static boolean isPrintableChar(int i) {
1813
1820
@ Specialization
1814
1821
@ TruffleBoundary
1815
1822
static boolean doString (String self ) {
1816
- for (int i = 0 ; i < self .length (); i ++) {
1817
- if (!isPrintableChar (self .codePointAt (i ))) {
1823
+ for (int i = 0 ; i < self .length ();) {
1824
+ int codePoint = self .codePointAt (i );
1825
+ if (!isPrintableChar (codePoint )) {
1818
1826
return false ;
1819
1827
}
1828
+ i += Character .charCount (codePoint );
1820
1829
}
1821
1830
return true ;
1822
1831
}
@@ -1839,10 +1848,12 @@ static boolean doString(String self) {
1839
1848
if (self .length () == 0 ) {
1840
1849
return false ;
1841
1850
}
1842
- for (int i = 0 ; i < self .length (); i ++) {
1843
- if (!StringUtils .isSpace (self .charAt (i ))) {
1851
+ for (int i = 0 ; i < self .length ();) {
1852
+ int codePoint = self .codePointAt (i );
1853
+ if (!StringUtils .isSpace (codePoint )) {
1844
1854
return false ;
1845
1855
}
1856
+ i += Character .charCount (codePoint );
1846
1857
}
1847
1858
return true ;
1848
1859
}
@@ -1865,7 +1876,7 @@ static boolean doString(String self) {
1865
1876
if (self .length () == 0 ) {
1866
1877
return false ;
1867
1878
}
1868
- for (int i = 0 ; i < self .length (); i ++ ) {
1879
+ for (int i = 0 ; i < self .length ();) {
1869
1880
int codePoint = self .codePointAt (i );
1870
1881
if (!expectLower ) {
1871
1882
if (Character .isTitleCase (codePoint ) || Character .isUpperCase (codePoint )) {
@@ -1883,6 +1894,7 @@ static boolean doString(String self) {
1883
1894
expectLower = false ;
1884
1895
}
1885
1896
}
1897
+ i += Character .charCount (codePoint );
1886
1898
}
1887
1899
return hasContent ;
1888
1900
}
@@ -1904,7 +1916,7 @@ static boolean doString(String self) {
1904
1916
if (self .length () == 0 ) {
1905
1917
return false ;
1906
1918
}
1907
- for (int i = 0 ; i < self .length (); i ++ ) {
1919
+ for (int i = 0 ; i < self .length ();) {
1908
1920
int codePoint = self .codePointAt (i );
1909
1921
if (!Character .isUpperCase (codePoint )) {
1910
1922
if (Character .toLowerCase (codePoint ) == Character .toUpperCase (codePoint )) {
@@ -1913,6 +1925,7 @@ static boolean doString(String self) {
1913
1925
return false ;
1914
1926
}
1915
1927
}
1928
+ i += Character .charCount (codePoint );
1916
1929
}
1917
1930
return uncased == 0 || self .length () > uncased ;
1918
1931
}
0 commit comments