Mozilla

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • XPCOM strings, hashtables questions

    4 answers - 1187 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    There were some points peterv raised in his r-'ing a patch for bug
    319768 which I need some clarification on.
    (1) >+ nsClassHashtable<nsStringHashKey, nsString
    mNamespaceURIMap;
    >+ nsClassHashtable<nsStringHashKey, nsStringmPrefixMap;
    >
    >Shouldn't these be nsDataHashTable's?
    >
    >I thought about that, but per
    >#
    >it appeared they should be nsClassHashTables.

    Then you should change
    + nsDataHashtable<nsStringHashKey, nsStringstepAttrsMap;
    Please check with bsmedberg.
    Should I use nsClassHashtable or nsDataHashtable?
    (2) Is there a better way to do this:
    +
    + if (total 1)
    + {
    + currentStep.Append('[');
    + currentStep.AppendInt(index);
    + currentStep.Append(']');
    + }
    (3) peterv made a reference to:
    aResult.AppendLiteral("\", '\"', \"");
    This isn't documented in the XPCM:Strings guide. Any pointers where I
    can find documentation on it, and learn how to use it properly?
    dev-tech-xpcom mailing list
    dev-tech-xpcom (AT) lists (DOT) mozilla.org
  • No.1 | | 1217 bytes | |

    Alex Vincent wrote:

    Should I use nsClassHashtable or nsDataHashtable?

    nsClassHashtable "owns" the pointers, and "delete"s them when an entry is
    removed.

    nsDataHashtable just holds a type in the entry.

    Which one you use depends on your needs in terms of cleaning up entries.

    (2) Is there a better way to do this:
    >+
    >+ if (total 1)
    >+ {
    >+ currentStep.Append('[');
    >+ currentStep.AppendInt(index);
    >+ currentStep.Append(']');
    >+ }


    No, that's good.

    (3) peterv made a reference to:
    >aResult.AppendLiteral("\", '\"', \"");


    This isn't documented in the XPCM:Strings guide. Any pointers where I
    can find documentation on it, and learn how to use it properly?

    Read the headers, of course!
    #460

    It is used for real literals which can be treated as a const char[] and not
    just a const char* this allows smart compilers to not have to do a
    strlen() on the buffer (because it's known at compile-time).

    dev-tech-xpcom mailing list
    dev-tech-xpcom (AT) lists (DOT) mozilla.org
  • No.2 | | 619 bytes | |

    Benjamin Smedberg wrote:
    nsClassHashtable "owns" the pointers, and "delete"s them when an entry
    is removed.

    nsDataHashtable just holds a type in the entry.

    Which one you use depends on your needs in terms of cleaning up entries.

    I think the question was whether nsDataHashtable is safe to use with nsString as
    the type.

    I almost want to say yes, for the same reason that it's safe to have nsString
    members, but does nsDataHashtable call the type destructor as needed?
    -Boris

    dev-tech-xpcom mailing list
    dev-tech-xpcom (AT) lists (DOT) mozilla.org
  • No.3 | | 579 bytes | |

    Boris Zbarsky wrote:

    >Which one you use depends on your needs in terms of cleaning up entries.


    I think the question was whether nsDataHashtable is safe to use with
    nsString as the type.

    I almost want to say yes, for the same reason that it's safe to have
    nsString members, but does nsDataHashtable call the type destructor as
    needed?

    Yes. Using nsDataHashtable<SomeKeyType, nsStringis safe (and not unusual).

    dev-tech-xpcom mailing list
    dev-tech-xpcom (AT) lists (DOT) mozilla.org
  • No.4 | | 411 bytes | |

    Boris Zbarsky wrote:
    >Which one you use depends on your needs in terms of cleaning up entries.


    I think the question was whether nsDataHashtable is safe to use with
    nsString as the type.

    Actually, the question was exactly as I wrote it: which one should I
    use? :)

    dev-tech-xpcom mailing list
    dev-tech-xpcom (AT) lists (DOT) mozilla.org

Re: XPCOM strings, hashtables questions


max 4000 letters.
Your nickname that display:
In order to stop the spam: 6 + 6 =
QUESTION ON "Mozilla"

EMSDN.COM