Ejemplo n.º 1
0
static inline HashSet<StringImpl*>& stringTable()
{
    // Once possible we should make this non-lazy (constructed in WTFThreadData's constructor).
    WTFThreadData& data = wtfThreadData();
    AtomicStringTable* table = data.atomicStringTable();
    if (UNLIKELY(!table))
        table = AtomicStringTable::create(data);
    return table->table();
}
Ejemplo n.º 2
0
Ref<StringImpl> AtomicString::addSlowCase(AtomicStringTable& stringTable, StringImpl& string)
{
    if (!string.length())
        return *StringImpl::empty();

    if (string.isSymbol()) {
        if (string.is8Bit())
            return *add(string.characters8(), string.length());
        return *add(string.characters16(), string.length());
    }

    ASSERT_WITH_MESSAGE(!string.isAtomic(), "AtomicString should not hit the slow case if the string is already atomic.");

    AtomicStringTableLocker locker;
    auto addResult = stringTable.table().add(&string);

    if (addResult.isNewEntry) {
        ASSERT(*addResult.iterator == &string);
        string.setIsAtomic(true);
    }

    return **addResult.iterator;
}