unify common function names between APIs




5 years ago
5 years ago


(Reporter: mmc, Unassigned)


Firefox Tracking Flags

(Not tracked)


I am constantly tripping up between using .Data() and .get() for nsACString vs nsAutoString, and likewise .Count() and .GetLength() for nsCOMArray and nsIArray and probably many more.

I'm not sure if this falls in the purview of MFBT, but it sure would be nice to have unified APIs so that developers don't have to waste time or mental energy accommodating for these differences.

Comment 1

5 years ago
The functions/classes you name are XPCOM, so this probably belongs there.
Component: MFBT → XPCOM
.Data() can be used just fine for nsAutoString, or indeed any string.

.get() has totally different behavior from .Data().  Specifically, it guarantees null-termination.  That's why there are two different APIs: they do different things.

nsCOMArray should just be removed, and we have bugs on that.

Comment 3

5 years ago
nsCOMArray should not be removed unless we can prove that nsTArray<nsCOMPtr> has the same codesize benefits (it did not when I last measured).

Bug 493711 made nsCOMArray support the same basic method names as nsTArray, I think.

nsIArray is probably not changeable given the addon-compat issues.
You need to log in before you can comment on or make changes to this bug.