I recently filed a bug (bug 792169) for adding NS_NewIMutableArray, in
service of deleting nsISupportsArray.  The reviewer asked me to use
more standard C++ instead of perpetuating the NS_New* idiom and I did
so, with a static |Create| member function.

However, looking through other code--especially the various bits under
dom/ that have been added for B2G--I see that the NS_New* style is alive
and well.

Points for NS_New*:

+ Avoid exporting internal datastructures;
+ Possibly more efficient than do_CreateInstance and friends;
- Usually requires %{C++ blocks in IDL files;
- Less C++-y.

Points for new and/or static member functions:

+ More C++-y;
+ Less function call overhead compared to NS_New* (modulo LTO);
- Drags in more headers.

...and there are probably other things that I haven't thought of for
both of them.

So which style do we want to embrace?  Or are there good reasons to
continue with both?

-Nathan
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to