Closed Bug 1372356 Opened 7 years ago Closed 7 years ago

RuntimeService::RegisterWorker/UnregisterWorker does unnecessary hashtable lookups

Categories

(Core :: DOM: Workers, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla56
Tracking Status
firefox56 --- fixed

People

(Reporter: MatsPalmgren_bugz, Assigned: MatsPalmgren_bugz)

Details

(Keywords: perf)

Attachments

(2 files)

      No description provided.
Summary: RuntimeService::RegisterWorker does unnecessary hashtable lookups → RuntimeService::RegisterWorker/UnregisterWorker does unnecessary hashtable lookups
Comment on attachment 8876886 [details] [diff] [review]
Use mWindowMap.LookupForAdd instead of Get+Put, and LookupRemoveIf instead of Get+Remove, to avoid unnecessary hashtable lookups

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

::: dom/workers/RuntimeService.cpp
@@ +1879,5 @@
> +    DebugOnly<bool> found = false;
> +    mWindowMap.LookupRemoveIf(window,
> +      [&aWorkerPrivate, &found] (nsTArray<WorkerPrivate*>* aWindowArray) {
> +        MOZ_ALWAYS_TRUE(aWindowArray->RemoveElement(aWorkerPrivate));
> +        found = true;

We are using this |found| pattern quite often with this function, maybe we should find some way of integrating it into the function itself?
Attachment #8876886 - Flags: review?(nfroyd) → review+
Attachment #8876882 - Flags: review?(nfroyd) → review+
Pushed by mpalmgren@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3ad2c67c6669
Use LookupForAdd instead of Get+Put to avoid unnecessary hashtable lookups.  r=froydnj
https://hg.mozilla.org/integration/mozilla-inbound/rev/dfd1cb941248
part 2 - Use mWindowMap.LookupForAdd instead of Get+Put, and LookupRemoveIf instead of Get+Remove, to avoid unnecessary hashtable lookups.  r=froydnj
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: