< prev index next >

src/share/vm/oops/symbol.cpp

Print this page

        

@@ -96,10 +96,29 @@
   return true;
 }
 
 
 // ------------------------------------------------------------------
+// Symbol::ends_with
+//
+// Tests if the symbol ends with the specified suffix of the given
+// length.
+bool Symbol::ends_with(const char* suffix, int len) const {
+  const int utf8_len = utf8_length();
+  if (len > utf8_len) return false;
+  int pos = utf8_len;
+  while (len-- > 0) {
+    pos--;
+    if (suffix[len] != (char) byte_at(pos))
+      return false;
+  }
+  assert(len == -1, "we should be at the beginning");
+  return true;
+}
+
+
+// ------------------------------------------------------------------
 // Symbol::index_of
 //
 // Finds if the given string is a substring of this symbol's utf8 bytes.
 // Return -1 on failure.  Otherwise return the first index where str occurs.
 int Symbol::index_of_at(int i, const char* str, int len) const {
< prev index next >