Console::IncreaseCounter does unnecessary hashtable lookups

RESOLVED FIXED in Firefox 56

Status

()

Core
DOM
P2
normal
RESOLVED FIXED
2 months ago
2 months ago

People

(Reporter: Mats Palmgren (vacation - back in August), Assigned: Mats Palmgren (vacation - back in August))

Tracking

(Blocks: 1 bug, {perf})

Trunk
mozilla56
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox56 fixed)

Details

Attachments

(1 attachment)

Comment hidden (empty)
Created attachment 8876860 [details] [diff] [review]
Use LookupForAdd instead of Get+Put to avoid unnecessary hashtable lookups

(This is another example where having a Remove method on EntryPtr
would save us a lookup.  I think using LookupForAdd in these cases
is still preferable to Get+Put since the Remove is very rare.)
Attachment #8876860 - Flags: review?(nfroyd)
(Filed bug 1372333 about adding a Remove() method.)
Blocks: 1372333
Comment on attachment 8876860 [details] [diff] [review]
Use LookupForAdd instead of Get+Put to avoid unnecessary hashtable lookups

Review of attachment 8876860 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/console/Console.cpp
@@ +2195,5 @@
>  
>    aCountLabel = string;
>  
> +  const bool maxCountersReached = mCounterRegistry.Count() >= MAX_PAGE_COUNTERS;
> +  auto entry = mCounterRegistry.LookupForAdd(aCountLabel);

Ew.  I think this could be avoided by making EntryPtr a little more powerful, even beyond adding a Remove() method.
Attachment #8876860 - Flags: review?(nfroyd) → review+

Comment 4

2 months ago
Pushed by mpalmgren@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/eb36d574ec6e
Use LookupForAdd instead of Get+Put to avoid unnecessary hashtable lookups.  r=froydnj
https://hg.mozilla.org/mozilla-central/rev/eb36d574ec6e
Status: NEW → RESOLVED
Last Resolved: 2 months ago
status-firefox56: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in before you can comment on or make changes to this bug.