File indexing completed on 2024-05-12 15:43:35
0001 /* 0002 * Copyright (C) 2007 Apple Inc. All rights reserved. 0003 * 0004 * Redistribution and use in source and binary forms, with or without 0005 * modification, are permitted provided that the following conditions 0006 * are met: 0007 * 0008 * 1. Redistributions of source code must retain the above copyright 0009 * notice, this list of conditions and the following disclaimer. 0010 * 2. Redistributions in binary form must reproduce the above copyright 0011 * notice, this list of conditions and the following disclaimer in the 0012 * documentation and/or other materials provided with the distribution. 0013 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 0014 * its contributors may be used to endorse or promote products derived 0015 * from this software without specific prior written permission. 0016 * 0017 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 0018 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 0019 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 0020 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 0021 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 0022 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 0023 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 0024 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0025 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0026 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0027 */ 0028 0029 #ifndef SymbolTable_h 0030 #define SymbolTable_h 0031 0032 #include "ustring.h" 0033 #include <wtf/AlwaysInline.h> 0034 0035 namespace KJS 0036 { 0037 0038 struct IdentifierRepHash : PtrHash<RefPtr<UString::Rep> > { 0039 static unsigned hash(const RefPtr<UString::Rep> &key) 0040 { 0041 return key->computedHash(); 0042 } 0043 static unsigned hash(UString::Rep *key) 0044 { 0045 return key->computedHash(); 0046 } 0047 }; 0048 0049 static ALWAYS_INLINE size_t missingSymbolMarker() 0050 { 0051 return std::numeric_limits<size_t>::max(); 0052 } 0053 0054 struct SymbolTableIndexHashTraits : HashTraits<size_t> { 0055 static const bool emptyValueIsZero = false; 0056 static size_t emptyValue() 0057 { 0058 return missingSymbolMarker(); 0059 } 0060 }; 0061 0062 typedef HashMap<RefPtr<UString::Rep>, size_t, IdentifierRepHash, HashTraits<RefPtr<UString::Rep> >, SymbolTableIndexHashTraits> SymbolTable; 0063 } // namespace KJS 0064 0065 #endif // SymbolTable_h