void RuleSet::addToRuleSet(const AtomicString& key, PendingRuleMap& map, const RuleData& ruleData) { OwnPtrWillBeMember<WillBeHeapLinkedStack<RuleData>>& rules = map.add(key, nullptr).storedValue->value; if (!rules) rules = adoptPtrWillBeNoop(new WillBeHeapLinkedStack<RuleData>); rules->push(ruleData); }
void RuleSet::compactPendingRules(PendingRuleMap& pendingMap, CompactRuleMap& compactMap) { PendingRuleMap::iterator end = pendingMap.end(); for (PendingRuleMap::iterator it = pendingMap.begin(); it != end; ++it) { OwnPtrWillBeRawPtr<WillBeHeapLinkedStack<RuleData> > pendingRules = it->value.release(); CompactRuleMap::ValueType* compactRules = compactMap.add(it->key, nullptr).storedValue; WillBeHeapTerminatedArrayBuilder<RuleData> builder(compactRules->value.release()); builder.grow(pendingRules->size()); while (!pendingRules->isEmpty()) { builder.append(pendingRules->peek()); pendingRules->pop(); } compactRules->value = builder.release(); } }
void RuleSet::addToRuleSet(StringImpl* key, PendingRuleMap& map, const RuleData& ruleData) { if (!key) return; OwnPtr<LinkedStack<RuleData> >& rules = map.add(key, nullptr).iterator->value; if (!rules) rules = adoptPtr(new LinkedStack<RuleData>); rules->push(ruleData); }