Closed
Bug 212468
Opened 21 years ago
Closed 21 years ago
rethink the hashtable usage in helperappservice
Categories
(Core Graveyard :: File Handling, defect, P1)
Core Graveyard
File Handling
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla1.5beta
People
(Reporter: Biesinger, Assigned: Biesinger)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
12.86 KB,
patch
|
bzbarsky
:
review+
darin.moz
:
superreview+
|
Details | Diff | Splinter Review |
Currently, the only entries that ever end up in the hashtable are those from defaultMimeEntries. which means that the table is rather useless, except to speed up mime type lookups by extension. so I would suggest removing that hashtable, removing rarely used entries from defaultMimeEntries, and in GetMimeTypeFromExtension just doing a linear search in defaultMimeEntries. The entries in there could be in the order xul,xml,rdf,gif,jpg,css,htm,html
Comment 1•21 years ago
|
||
If you're going to remove the ability to add new entries, why not just make a gperf table out of the existing defaultMimeEntries?
Assignee | ||
Comment 2•21 years ago
|
||
well... even today, that hashtable is not being added to... I'll consider that, but wouldn't that add a compile-time dependency on gperf?
Comment 3•21 years ago
|
||
I think alecf or shaver might know how to insert gperfed code into the build so that it can be built on machines without gperf. Using gperf at all here is just a suggestion. Although I think lookup will beat a linear search here, it may be over-optimization depending on how frequently this is called.
Comment 4•21 years ago
|
||
It's called somewhat frequently at startup (like for every .xul, .css, .gif, .rdf, .xml, etc in the chrome). But would a lookup really beat a linear search over 5-10 entries that we can order in order of frequency?
Comment 5•21 years ago
|
||
Depends on how biased the frequencies are. The tradeoff is around when the expected number of lookups for linear search crosses two (assuming the perfect hash code generator is good). If the number of types really can be cut to five, then simplicity wins. The difference between the two in that case should be microseconds.
Assignee | ||
Comment 6•21 years ago
|
||
Assignee | ||
Updated•21 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 7•21 years ago
|
||
Comment on attachment 127752 [details] [diff] [review] patch Here's the count of the extensions used at startup on my system (Win32, Classic) GIF: 29 XML: 24 RDF: 10 XUL: 3
Attachment #127752 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•21 years ago
|
Priority: -- → P1
Target Milestone: --- → mozilla1.5beta
Comment 8•21 years ago
|
||
Comment on attachment 127752 [details] [diff] [review] patch >+ { TEXT_PLAIN, "txt,text", "Text File", 'TEXT', 'ttxt' }, >+#ifdef MOZ_SVG >+ { "image/svg+xml", "svg", "Scalable Vector Graphics", 'svg ', 'ttxt' }, >+#endif ..... Hey, as long as you're changing the order of these, please put them in a logical order? Eg, JPEG and GIF should be somewhere near PNG.... Also, I see no reason to have that #ifdef there now that this is not in the "no override possible" list. Finally, please put >+ { APPLICATION_XPINSTALL, "xpi", "XPInstall Install", 'xpi*','MOSS' }, in the "no override possible" list too, just in case. r=me with these changes.
Attachment #127752 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Comment 9•21 years ago
|
||
Comment on attachment 127752 [details] [diff] [review] patch bz: ok, I'll make those changes
Attachment #127752 -
Flags: superreview?(darin)
Comment 10•21 years ago
|
||
Comment on attachment 127752 [details] [diff] [review] patch lot's of code removal... very nice. sr=darin
Attachment #127752 -
Flags: superreview?(darin) → superreview+
Assignee | ||
Comment 11•21 years ago
|
||
requested changes made. I made the order mostly alphabetical. Checking in nsExternalHelperAppService.cpp; /cvsroot/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp,v <-- nsE xternalHelperAppService.cpp new revision: 1.201; previous revision: 1.200 done Checking in nsExternalHelperAppService.h; /cvsroot/mozilla/uriloader/exthandler/nsExternalHelperAppService.h,v <-- nsExt ernalHelperAppService.h new revision: 1.46; previous revision: 1.45 done
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 12•21 years ago
|
||
oh right, to address the gperf question: I ended up getting 4 types that had to be fast, so I used a normal array. (there are ~8 entries in that array, but for the last 4, speed doesn't matter so much)
Updated•8 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•