Closed Bug 297315 Opened 19 years ago Closed 19 years ago

Sort nsICategoryManager.enumerateCategory alphabetically

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.8beta3

People

(Reporter: benjamin, Assigned: benjamin)

References

Details

Attachments

(1 file)

I have found myself several times sorting the results of
nsICategoryManager.enumerateCategory alphabetically in client code. It is very
simple to do this before handing out the enumerator, and a lot harder afterwards.
Attachment #185857 - Flags: review?(darin)
Comment on attachment 185857 [details] [diff] [review]
Sort enumerateCategory() and remove some manual sorting code, rev. 1

Please add documentation to nsICategoryManager.idl
Attachment #185857 - Flags: review?(darin) → review+
darin, we discussed this over irc.  no changes should be made to the IDL as it
is frozen and any any mention of ordering will either violate the origanal
contract or assert the behavior of some implementation. 
Then perhaps the IDL should state clearly that the ordering is not specified. 
Otherwise, someone might look at the implementation and make the false
assumption that the result is always sorted.
good idea.
Of course, it also means that our own code would be violating that comment :-/

Maybe somehow comment that in Gecko 1.8 and later, the nsICategoryManager
implemented by XPCOM returns sorted results?
Isn't that exactly what my change to nsXPCOMCID.h does?
Attachment #185857 - Flags: approval-aviary1.1a2?
Attachment #185857 - Flags: approval-aviary1.1a2? → approval-aviary1.1a2+
Yes, it does.  But, nsICategoryManager itself doesn't specify or not specify. 
It should probably say something.  Maybe say that sorting behavior is
implementation specific (e.g., see nsXPCOMCID.h for information about the XPCOM
category manager implementation).
Fixed on trunk. There was an error in nsCommandLine.cpp (rv = NS_ERROR_ABORT
instead of rv == NS_ERROR_ABORT) which is now also fixed.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.8beta3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: