- struct CharBuffer {
- const T* s;
- unsigned int length;
- };
-
- template <typename T>
- struct IdentifierCharBufferTranslator {
- static unsigned hash(const CharBuffer<T>& buf)
- {
- return StringHasher::computeHash<T>(buf.s, buf.length);
- }
-
- static bool equal(StringImpl* str, const CharBuffer<T>& buf)
- {
- return Identifier::equal(str, buf.s, buf.length);
- }
-
- static void translate(StringImpl*& location, const CharBuffer<T>& buf, unsigned hash)
- {
- T* d;
- StringImpl* r = StringImpl::createUninitialized(buf.length, d).leakRef();
- for (unsigned i = 0; i != buf.length; i++)
- d[i] = buf.s[i];
- r->setHash(hash);
- location = r;
- }
- };
-
- template <typename T>
- PassRefPtr<StringImpl> Identifier::add(JSGlobalData* globalData, const T* s, int length)