[Webkit-unassigned] [Bug 5262] XMLSerializer drops Namespace information

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Mar 9 06:45:10 PST 2007


http://bugs.webkit.org/show_bug.cgi?id=5262


darin at apple.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #13536|review?                     |review+
               Flag|                            |




------- Comment #14 from darin at apple.com  2007-03-09 06:45 PDT -------
(From update of attachment 13536)
+    // Set pre to be emptyAtom if prefix is empty so that all empty
AtomicStrings will map to the same key in the hash.

Comment should really mention null, because there are only two empty atomic
strings: null and empty.

The code below:

+    // Set pre to be emptyAtom if prefix is empty so that all empty
AtomicStrings will map to the same key in the hash.
+    const AtomicString& pre = prefix.isEmpty() ? emptyAtom : prefix;
+    AtomicString foundNS = namespaces.get(pre.impl());
+    if (foundNS.isEmpty() || (foundNS != ns)) {
+        namespaces.set(pre.impl(), ns.impl());
+        return " xmlns" + (!prefix.isEmpty() ? ":" + prefix : "") + "=\"" + ns
+ "\"";
+    }
+    return "";

seems more natural to me, written this way:

    if (ns.isEmpty())
        return "";
    // Use emptyAtom's impl() for both null and empty strings, since the
HashMap can't handle 0 as a key.
    AtomicStringImpl* pre = prefix.isEmpty() ? emptyAtom.impl() :
prefix.impl();
    AtomicStringImpl* foundNS = namespaces.get(pre.impl());
    if (foundNS != ns.impl()) {
        namespaces.set(pre.impl(), ns.impl());
        return " xmlns" + (!prefix.isEmpty() ? ":" + prefix : "") + "=\"" + ns
+ "\"";
    }
    return "";

Since the map is of AtomicStringImpl*, the code can work with those.

With the special case for ns, you can simplify callers of addNamespace -- they
don't need to check for the ns.isEmpty() special case.

But those changes are optional. r=me


-- 
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list