Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions user/super/com/google/gwt/emul/java/lang/String.java
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public String concat(String str) {
}

public boolean contains(CharSequence s) {
return indexOf(s.toString()) != -1;
return asNativeString().includes(s.toString());
}

public boolean contentEquals(CharSequence cs) {
Expand All @@ -411,9 +411,7 @@ public boolean contentEquals(StringBuffer sb) {
}

public boolean endsWith(String suffix) {
// If IE8 supported negative start index, we could have just used "-suffixlength".
int suffixlength = suffix.length();
return asNativeString().substr(length() - suffixlength, suffixlength).equals(suffix);
return asNativeString().endsWith(suffix);
}

// Marked with @DoNotInline because we don't have static eval for "==" yet.
Expand Down Expand Up @@ -691,11 +689,11 @@ public String[] split(String regex, int maxMatch) {
}

public boolean startsWith(String prefix) {
return startsWith(prefix, 0);
return asNativeString().startsWith(prefix);
}

public boolean startsWith(String prefix, int toffset) {
return toffset >= 0 && asNativeString().substr(toffset, prefix.length()).equals(prefix);
return asNativeString().startsWith(prefix, toffset);
}

@Override
Expand Down Expand Up @@ -991,11 +989,16 @@ private static class NativeString {
public static native String fromCharCode(char x);
public int length;
public native char charCodeAt(int index);
public native boolean endsWith(String suffix);
public native int indexOf(String str);
public native int indexOf(String str, int startIndex);
public native boolean includes(String str);
public native boolean includes(String str, int startIndex);
public native int lastIndexOf(String str);
public native int lastIndexOf(String str, int start);
public native String replace(NativeRegExp regex, String replace);
public native boolean startsWith(String prefix);
public native boolean startsWith(String prefix, int toffset);
public native String substr(int beginIndex);
public native String substr(int beginIndex, int len);
public native String toLocaleLowerCase();
Expand Down
Loading