Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(579)

Unified Diff: Source/core/css/RuleSet.h

Issue 17616009: RuleSet should use malloc rather than Vector (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make fancy Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/css/RuleSet.h
diff --git a/Source/core/css/RuleSet.h b/Source/core/css/RuleSet.h
index 4ce7582c4d1335d157bb485a52b33338a167543b..39474cd2f7781403519e4ab8224953d1ebcfb936 100644
--- a/Source/core/css/RuleSet.h
+++ b/Source/core/css/RuleSet.h
@@ -27,6 +27,7 @@
#include "wtf/Forward.h"
#include "wtf/HashMap.h"
#include "wtf/LinkedStack.h"
+#include "wtf/OwnArrayPtr.h"
namespace WebCore {
@@ -51,6 +52,7 @@ class StyleRuleRegion;
class StyleSheetContents;
class RuleData {
+ NEW_DELETE_SAME_AS_MALLOC_FREE;
public:
RuleData(StyleRule*, unsigned selectorIndex, unsigned position, AddRuleFlags);
@@ -59,6 +61,9 @@ public:
const CSSSelector* selector() const { return m_rule->selectorList().selectorAt(m_selectorIndex); }
unsigned selectorIndex() const { return m_selectorIndex; }
+ bool isLastInArray() const { return m_isLastInArray; }
+ void setLastInArray(bool flag) { m_isLastInArray = flag ? 1 : 0; }
esprehn 2013/06/26 00:37:33 I don't think you need the ternary in here.
abarth-chromium 2013/06/26 00:57:00 Done.
+
bool hasFastCheckableSelector() const { return m_hasFastCheckableSelector; }
bool hasMultipartSelector() const { return m_hasMultipartSelector; }
bool hasRightmostSelectorMatchingHTMLBasedOnRuleHash() const { return m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash; }
@@ -75,7 +80,8 @@ public:
private:
StyleRule* m_rule;
- unsigned m_selectorIndex : 13;
+ unsigned m_selectorIndex : 12;
+ unsigned m_isLastInArray : 1; // We store an array of RuleData objects in a primitive array.
// This number was picked fairly arbitrarily. We can probably lower it if we need to.
// Some simple testing showed <100,000 RuleData's on large sites.
unsigned m_position : 18;
@@ -111,10 +117,10 @@ public:
const RuleFeatureSet& features() const { return m_features; }
- const Vector<RuleData>* idRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRules); return m_idRules.get(key); }
- const Vector<RuleData>* classRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRules); return m_classRules.get(key); }
- const Vector<RuleData>* tagRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRules); return m_tagRules.get(key); }
- const Vector<RuleData>* shadowPseudoElementRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRules); return m_shadowPseudoElementRules.get(key); }
+ const RuleData* idRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRules); return m_idRules.get(key); }
+ const RuleData* classRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRules); return m_classRules.get(key); }
+ const RuleData* tagRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRules); return m_tagRules.get(key); }
+ const RuleData* shadowPseudoElementRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRules); return m_shadowPseudoElementRules.get(key); }
esprehn 2013/06/26 00:37:33 We might consider a WTF class someday that does th
abarth-chromium 2013/06/26 00:57:00 Yeah.
const Vector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pendingRules); return &m_linkPseudoClassRules; }
const Vector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules); return &m_cuePseudoRules; }
const Vector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendingRules); return &m_focusPseudoClassRules; }
@@ -145,7 +151,7 @@ public:
private:
typedef HashMap<AtomicStringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingRuleMap;
- typedef HashMap<AtomicStringImpl*, OwnPtr<Vector<RuleData> > > CompactRuleMap;
+ typedef HashMap<AtomicStringImpl*, OwnPtr<RuleData> > CompactRuleMap;
RuleSet()
: m_ruleCount(0)

Powered by Google App Engine
This is Rietveld 408576698