source: webkit/trunk/JavaScriptCore/kjs/PropertyNameArray.cpp@ 34854

Last change on this file since 34854 was 34607, checked in by [email protected], 17 years ago

Reviewed by Geoff Garen.

Make Identifier construction use an explicitly passed IdentifierTable.

No change on SunSpider total.

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// -*- mode: c++; c-basic-offset: 4 -*-
2/*
3 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 */
21
22#include "config.h"
23#include "PropertyNameArray.h"
24
25namespace KJS {
26
27static const size_t setThreshold = 20;
28
29void PropertyNameArray::add(UString::Rep* identifier)
30{
31 ASSERT(identifier == &UString::Rep::null || identifier == &UString::Rep::empty || identifier->identifierTable);
32
33 size_t size = m_vector.size();
34 if (size < setThreshold) {
35 for (size_t i = 0; i < size; ++i) {
36 if (identifier == m_vector[i].ustring().rep())
37 return;
38 }
39 } else {
40 if (m_set.isEmpty()) {
41 for (size_t i = 0; i < size; ++i)
42 m_set.add(m_vector[i].ustring().rep());
43 }
44 if (!m_set.add(identifier).second)
45 return;
46 }
47
48 m_vector.append(Identifier(m_globalData, identifier));
49}
50
51} // namespace KJS
Note: See TracBrowser for help on using the repository browser.