Title: [149632] trunk/Source/WebCore
- Revision
- 149632
- Author
- [email protected]
- Date
- 2013-05-06 13:15:19 -0700 (Mon, 06 May 2013)
Log Message
Use OwnPtr instead of deleteAllValues in SVGAttributeToPropertyMap
https://bugs.webkit.org/show_bug.cgi?id=115653
Reviewed by Andreas Kling.
Also made a few style fixes to the code at the same time.
* svg/properties/SVGAttributeToPropertyMap.cpp:
(WebCore::SVGAttributeToPropertyMap::addProperties): Changed argument to
const because there was no reason for it to be non-const. Added calls to
get() since the items in the map are now OwnPtr. Added a couple FIXMEs
about performance mistakes.
(WebCore::SVGAttributeToPropertyMap::addProperty): Added a FIXME about
a small performance mistake, and updated to use OwnPtr instead of raw
pointers.
(WebCore::SVGAttributeToPropertyMap::synchronizeProperties): Added a call
to get().
* svg/properties/SVGAttributeToPropertyMap.h: Removed now-unneeded
constructor and destructor definitions. Changed the type for the
addProperties to be const&. Added a comment about incorrect function
naming. Changed the type of the map data member to use OwnPtr.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (149631 => 149632)
--- trunk/Source/WebCore/ChangeLog 2013-05-06 20:13:08 UTC (rev 149631)
+++ trunk/Source/WebCore/ChangeLog 2013-05-06 20:15:19 UTC (rev 149632)
@@ -1,3 +1,28 @@
+2013-05-06 Darin Adler <[email protected]>
+
+ Use OwnPtr instead of deleteAllValues in SVGAttributeToPropertyMap
+ https://bugs.webkit.org/show_bug.cgi?id=115653
+
+ Reviewed by Andreas Kling.
+
+ Also made a few style fixes to the code at the same time.
+
+ * svg/properties/SVGAttributeToPropertyMap.cpp:
+ (WebCore::SVGAttributeToPropertyMap::addProperties): Changed argument to
+ const because there was no reason for it to be non-const. Added calls to
+ get() since the items in the map are now OwnPtr. Added a couple FIXMEs
+ about performance mistakes.
+ (WebCore::SVGAttributeToPropertyMap::addProperty): Added a FIXME about
+ a small performance mistake, and updated to use OwnPtr instead of raw
+ pointers.
+ (WebCore::SVGAttributeToPropertyMap::synchronizeProperties): Added a call
+ to get().
+
+ * svg/properties/SVGAttributeToPropertyMap.h: Removed now-unneeded
+ constructor and destructor definitions. Changed the type for the
+ addProperties to be const&. Added a comment about incorrect function
+ naming. Changed the type of the map data member to use OwnPtr.
+
2013-05-06 Antti Koivisto <[email protected]>
Remove more code that was only needed for younger/older shadow trees
Modified: trunk/Source/WebCore/svg/properties/SVGAttributeToPropertyMap.cpp (149631 => 149632)
--- trunk/Source/WebCore/svg/properties/SVGAttributeToPropertyMap.cpp 2013-05-06 20:13:08 UTC (rev 149631)
+++ trunk/Source/WebCore/svg/properties/SVGAttributeToPropertyMap.cpp 2013-05-06 20:15:19 UTC (rev 149632)
@@ -27,15 +27,19 @@
namespace WebCore {
-void SVGAttributeToPropertyMap::addProperties(SVGAttributeToPropertyMap& map)
+void SVGAttributeToPropertyMap::addProperties(const SVGAttributeToPropertyMap& map)
{
- AttributeToPropertiesMap::iterator end = map.m_map.end();
- for (AttributeToPropertiesMap::iterator it = map.m_map.begin(); it != end; ++it) {
- PropertiesVector* vector = it->value;
+ AttributeToPropertiesMap::const_iterator end = map.m_map.end();
+ for (AttributeToPropertiesMap::const_iterator it = map.m_map.begin(); it != end; ++it) {
+ const PropertiesVector* vector = it->value.get();
ASSERT(vector);
- PropertiesVector::iterator vectorEnd = vector->end();
- for (PropertiesVector::iterator vectorIt = vector->begin(); vectorIt != vectorEnd; ++vectorIt)
+ // FIXME: This looks up the attribute name in the hash table for each property, even though all the
+ // properties in a single vector are guaranteed to have the same attribute name.
+ // FIXME: This grows the vector one item at a time, even though we know up front exactly how many
+ // elements we are adding to the vector.
+ PropertiesVector::const_iterator vectorEnd = vector->end();
+ for (PropertiesVector::const_iterator vectorIt = vector->begin(); vectorIt != vectorEnd; ++vectorIt)
addProperty(*vectorIt);
}
}
@@ -48,9 +52,10 @@
vector->append(info);
return;
}
- PropertiesVector* vector = new PropertiesVector;
+ // FIXME: This does a second hash table lookup, but with HashMap::add we could instead do only one.
+ OwnPtr<PropertiesVector> vector = adoptPtr(new PropertiesVector);
vector->append(info);
- m_map.set(info->attributeName, vector);
+ m_map.set(info->attributeName, vector.release());
}
void SVGAttributeToPropertyMap::animatedPropertiesForAttribute(SVGElement* ownerType, const QualifiedName& attributeName, Vector<RefPtr<SVGAnimatedProperty> >& properties)
@@ -81,7 +86,7 @@
ASSERT(contextElement);
AttributeToPropertiesMap::iterator end = m_map.end();
for (AttributeToPropertiesMap::iterator it = m_map.begin(); it != end; ++it) {
- PropertiesVector* vector = it->value;
+ PropertiesVector* vector = it->value.get();
ASSERT(vector);
PropertiesVector::iterator vectorEnd = vector->end();
Modified: trunk/Source/WebCore/svg/properties/SVGAttributeToPropertyMap.h (149631 => 149632)
--- trunk/Source/WebCore/svg/properties/SVGAttributeToPropertyMap.h 2013-05-06 20:13:08 UTC (rev 149631)
+++ trunk/Source/WebCore/svg/properties/SVGAttributeToPropertyMap.h 2013-05-06 20:15:19 UTC (rev 149632)
@@ -31,14 +31,13 @@
class SVGAttributeToPropertyMap {
public:
- SVGAttributeToPropertyMap() { }
- ~SVGAttributeToPropertyMap() { deleteAllValues(m_map); }
-
bool isEmpty() const { return m_map.isEmpty(); }
- void addProperties(SVGAttributeToPropertyMap&);
+ void addProperties(const SVGAttributeToPropertyMap&);
void addProperty(const SVGPropertyInfo*);
+ // FIXME: To match WebKit coding style either these functions should have return values instead of out parameters,
+ // or the word "get" should be added as a prefix to their names.
void animatedPropertiesForAttribute(SVGElement* contextElement, const QualifiedName& attributeName, Vector<RefPtr<SVGAnimatedProperty> >&);
void animatedPropertyTypeForAttribute(const QualifiedName& attributeName, Vector<AnimatedPropertyType>&);
@@ -50,7 +49,7 @@
PassRefPtr<SVGAnimatedProperty> animatedProperty(SVGElement* contextElement, const QualifiedName& attributeName, const SVGPropertyInfo*);
typedef Vector<const SVGPropertyInfo*> PropertiesVector;
- typedef HashMap<QualifiedName, PropertiesVector*> AttributeToPropertiesMap;
+ typedef HashMap<QualifiedName, OwnPtr<PropertiesVector> > AttributeToPropertiesMap;
AttributeToPropertiesMap m_map;
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes