gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/PropertyList.cpp


From: Chad Musick
Subject: [Gnash-commit] gnash ChangeLog server/PropertyList.cpp
Date: Wed, 14 Nov 2007 00:21:34 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Chad Musick <cmusick>   07/11/14 00:21:34

Modified files:
        .              : ChangeLog 
        server         : PropertyList.cpp 

Log message:
        Add some strictness to finding -- we should be quicker to find things 
for
        reading than for writing.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4850&r2=1.4851
http://cvs.savannah.gnu.org/viewcvs/gnash/server/PropertyList.cpp?cvsroot=gnash&r1=1.23&r2=1.24

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4850
retrieving revision 1.4851
diff -u -b -r1.4850 -r1.4851
--- ChangeLog   13 Nov 2007 20:56:09 -0000      1.4850
+++ ChangeLog   14 Nov 2007 00:21:33 -0000      1.4851
@@ -1,3 +1,8 @@
+2007-11-14 Chad Musick <address@hidden>
+
+       * server/PropertyList.cpp: Be stricter about checking for things that
+         could make insertions fail.
+
 2007-11-13 Sandro Santilli <address@hidden>
 
        * testsuite/actionscript.all/targetPath.as: reverted last change, the

Index: server/PropertyList.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/PropertyList.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- server/PropertyList.cpp     24 Oct 2007 22:43:23 -0000      1.23
+++ server/PropertyList.cpp     14 Nov 2007 00:21:34 -0000      1.24
@@ -46,7 +46,7 @@
 PropertyList&
 PropertyList::operator=(const PropertyList& pl)
 {
-       if ( this != &pl )
+       if (this != &pl)
        {
                clear();
                import(pl);
@@ -55,19 +55,19 @@
 }
 
 // Should find in any namespace if nsId is 0, and any namespace should find
-// something in namespace 0.
+// something in namespace 0, unless it is strict.
 static inline
 PropertyList::container::iterator
 iterator_find(PropertyList::container &p, string_table::key name,
-       string_table::key nsId)
+       string_table::key nsId, bool strict)
 {
-       if (nsId)
+       if (nsId || strict)
        {
                PropertyList::container::iterator i =
                        p.find(boost::make_tuple(name, nsId));
                if (i != p.end())
                        return i;
-               return p.find(boost::make_tuple(name, 0));
+               return strict ? p.end() : p.find(boost::make_tuple(name, 0));
        }
 
        return p.find(boost::make_tuple(name));
@@ -141,7 +141,7 @@
 PropertyList::getValue(const string_table::key key, as_value& val,
                as_object& this_ptr, const string_table::key nsId) 
 {
-       container::iterator found = iterator_find(_props, key, nsId);
+       container::iterator found = iterator_find(_props, key, nsId, false);
        if (found == _props.end())
                return false;
 
@@ -153,7 +153,7 @@
 PropertyList::setValue(string_table::key key, as_value val,
                as_object& this_ptr, string_table::key nsId)
 {
-       container::iterator found = iterator_find(_props, key, nsId);
+       container::iterator found = iterator_find(_props, key, nsId, true);
        
        if (found == _props.end())
        {
@@ -171,6 +171,7 @@
                return false;
        }
 
+       // This should be okay, since val is the only update here.
        const_cast<Property*>(&(*found))->setValue(this_ptr, val);
        return true;
 }
@@ -179,7 +180,7 @@
 PropertyList::setFlags(string_table::key key,
                int setFlags, int clearFlags, string_table::key nsId)
 {
-       container::iterator found = iterator_find(_props, key, nsId);
+       container::iterator found = iterator_find(_props, key, nsId, false);
        if ( found == _props.end() ) return false;
 
        as_prop_flags& f = const_cast<as_prop_flags&>(found->getFlags());
@@ -207,7 +208,7 @@
 Property*
 PropertyList::getProperty(string_table::key key, string_table::key nsId)
 {
-       container::iterator found = iterator_find(_props, key, nsId);
+       container::iterator found = iterator_find(_props, key, nsId, false);
        if (found == _props.end()) return NULL;
        return const_cast<Property*>(&(*found));
 }
@@ -216,7 +217,7 @@
 PropertyList::delProperty(string_table::key key, string_table::key nsId)
 {
        //GNASH_REPORT_FUNCTION;
-       container::iterator found = iterator_find(_props, key, nsId);
+       container::iterator found = iterator_find(_props, key, nsId, false);
        if (found == _props.end())
        {
                return std::make_pair(false,false);
@@ -272,6 +273,28 @@
 }
 
 void
+PropertyList::enumerateKeys(SafeStack<as_value>& stack,
+       propNameSet& donelist) const
+{
+       string_table& st = VM::get().getStringTable();
+       for (container::const_iterator i = _props.begin(), ie = _props.end();
+               i != ie; ++i)
+       {
+               if (i->getFlags().get_dont_enum())
+                       continue;
+
+               if (donelist.insert(std::make_pair(i->mName, 
i->mNamespace)).second)
+               {
+                       if (i->mNamespace)
+                               stack.push(as_value(st.value(i->mName) + "." +
+                                       st.value(i->mNamespace)));
+                       else
+                               stack.push(as_value(st.value(i->mName)));
+               }
+       }
+}
+
+void
 PropertyList::enumerateKeyValue(as_object& this_ptr, std::map<std::string, 
std::string>& to) 
 {
        string_table& st = VM::get().getStringTable();
@@ -313,7 +336,8 @@
                itEnd = o._props.end(); it != itEnd; ++it)
        {
                // overwrite any previous property with this name
-               container::iterator found = iterator_find(_props, it->mName, 
it->mNamespace);
+               container::iterator found = iterator_find(_props, it->mName,
+                       it->mNamespace, true);
                if (found != _props.end())
                {
                        Property a = *it;
@@ -336,12 +360,13 @@
        Property a(key, nsId, &getter, &setter);
        a.setOrder(- ++mDefaultOrder - 1);
 
-       container::iterator found = iterator_find(_props, key, nsId);
-       if (found != _props.end())
+       container::iterator found = iterator_find(_props, key, nsId, true);
+       if (found != _props.end() && found->mName == key && found->mNamespace 
== nsId)
        {
                // copy flags from previous member (even if it's a normal 
member ?)
                as_prop_flags& f = a.getFlags();
                f = found->getFlags();
+               a.setOrder(found->getOrder()); // Override order to match 
previous.
                _props.replace(found, a);
        }
        else
@@ -356,7 +381,7 @@
 PropertyList::addDestructiveGetterSetter(string_table::key key,
        as_function& getter, as_function& setter, string_table::key nsId)
 {
-       container::iterator found = iterator_find(_props, key, nsId);
+       container::iterator found = iterator_find(_props, key, nsId, true);
        if (found != _props.end())
                return false; // Already exists.
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]