Example #1
0
 public LuaString get(LuaString s) {
   final int index = s.hashCode() & (RECENT_STRINGS_CACHE_SIZE - 1);
   final LuaString cached = (LuaString) recent_short_strings[index];
   if (cached != null && s.raweq(cached)) return cached;
   recent_short_strings[index] = s;
   return s;
 }
Example #2
0
 /**
  * Find the index of a string starting at a point in this string
  *
  * @param s the string to search for
  * @param start the first index in the string
  * @return index of first match found, or -1 if not found.
  */
 public int indexOf(LuaString s, int start) {
   final int slen = s.length();
   final int limit = m_length - slen;
   for (int i = start; i <= limit; ++i) {
     if (equals(m_bytes, m_offset + i, s.m_bytes, s.m_offset, slen)) return i;
   }
   return -1;
 }
Example #3
0
 /**
  * Find the last index of a string in this string
  *
  * @param s the string to search for
  * @return index of last match found, or -1 if not found.
  */
 public int lastIndexOf(LuaString s) {
   final int slen = s.length();
   final int limit = m_length - slen;
   for (int i = limit; i >= 0; --i) {
     if (equals(m_bytes, m_offset + i, s.m_bytes, s.m_offset, slen)) return i;
   }
   return -1;
 }
Example #4
0
 public boolean raweq(LuaString s) {
   if (this == s) return true;
   if (s.m_length != m_length) return false;
   if (s.m_bytes == m_bytes && s.m_offset == m_offset) return true;
   if (s.hashCode() != hashCode()) return false;
   for (int i = 0; i < m_length; i++)
     if (s.m_bytes[s.m_offset + i] != m_bytes[m_offset + i]) return false;
   return true;
 }