Changeset 27385 in webkit for trunk/JavaScriptCore/wtf


Ignore:
Timestamp:
Nov 2, 2007, 5:30:44 PM (18 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

Reviewed by Maciej.

  • wtf/HashMap.h: Added take function. Simplistic implementation for now, but still does only one hash table lookup.
  • kjs/array_instance.cpp: (KJS::ArrayInstance::put): Use take rather than a find followed by a remove.

WebCore:

Reviewed by Maciej.

  • use the new HashMap::take function where appropriate
  • bindings/js/kjs_binding.cpp: (KJS::addWrapper): Made an inline rather than a macro; inlines good, macros bad. (KJS::removeWrapper): Ditto. (KJS::removeWrappers): Ditto. (KJS::ScriptInterpreter::putDOMObject): Use the inline instead of the macro. (KJS::ScriptInterpreter::forgetDOMObject): Ditto. This involves using take instead of remove -- in theory ever so slightly less efficient, but I think it's fine. (KJS::ScriptInterpreter::forgetDOMNodeForDocument): Ditto. (KJS::ScriptInterpreter::putDOMNodeForDocument): Use the inline instead of the macro. (KJS::ScriptInterpreter::forgetAllDOMNodesForDocument): Use take instead of find/remove. (KJS::ScriptInterpreter::updateDOMNodeDocument): Use the inlines instead of the macros.
  • bindings/js/kjs_window.cpp: (KJS::Window::clearTimeout): Use take instead of find/remove.
  • bridge/mac/AXObjectCacheMac.mm: (WebCore::AXObjectCache::remove): Ditto.
  • page/AnimationController.cpp: (WebCore::AnimationControllerPrivate::clear): Ditto.
  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::~RenderBlock): Ditto. (WebCore::RenderBlock::setDesiredColumnCountAndWidth): Ditto.
  • rendering/RootInlineBox.cpp: Ditto.(WebCore::RootInlineBox::detachEllipsisBox): Ditto.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/HashMap.h

    r27176 r27385  
    11// -*- mode: c++; c-basic-offset: 4 -*-
    22/*
    3  * This file is part of the KDE libraries
    4  *
    5  * Copyright (C) 2005, 2006 Apple Computer, Inc.
     3 * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
    64 *
    75 * This library is free software; you can redistribute it and/or
     
    9896
    9997        void remove(const KeyType&);
    100         void remove(iterator it);
     98        void remove(iterator);
    10199        void clear();
     100
     101        MappedType take(const KeyType&); // efficient combination of get with remove
    102102
    103103    private:
     
    325325    }
    326326
     327    template<typename T, typename U, typename V, typename W, typename MappedTraits>
     328    typename HashMap<T, U, V, W, MappedTraits>::MappedType
     329    HashMap<T, U, V, W, MappedTraits>::take(const KeyType& key)
     330    {
     331        // This can probably be made more efficient to avoid ref/deref churn.
     332        iterator it = find(key);
     333        if (it == end())
     334            return MappedTraits::emptyValue();
     335        typename HashMap<T, U, V, W, MappedTraits>::MappedType result = it->second;
     336        remove(it);
     337        return result;
     338    }
     339
    327340    template<typename T, typename U, typename V, typename W, typename X>
    328341    bool operator==(const HashMap<T, U, V, W, X>& a, const HashMap<T, U, V, W, X>& b)
Note: See TracChangeset for help on using the changeset viewer.