Closed Bug 1374089 Opened 4 years ago Closed 4 years ago

LayerTransactionParent does unnecessary hashtable lookups

Categories

(Core :: Graphics: Layers, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla56
Tracking Status
firefox56 --- fixed

People

(Reporter: mats, Assigned: mats)

References

Details

(Keywords: perf)

Attachments

(2 files)

No description provided.
I think it's a bit silly to use nsDataHashtable with a RefPtr<> when we
have a dedicated nsRefPtrHashtable class for that use case.  Also, this
avoid unnecessary ref counting in AsLayer().
Attachment #8878913 - Flags: review?(nfroyd)
No longer blocks: 1371094
Depends on: 1371094
Comment on attachment 8878912 [details] [diff] [review]
part 1 - Use LookupForAdd instead of Contains+Put, and remove an unnecessary Contains call before GetAndRemove, to avoid unnecessary hashtable lookups

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

::: gfx/layers/ipc/LayerTransactionParent.cpp
@@ +1028,2 @@
>    }
> +  return IPC_FAIL_NO_REASON(this);

Maybe write this as:

if (!aHandle) {
  return IPC_FAIL_NO_REASON(this);
}

Maybe<RefPtr<Layer>> maybeLayer = ...
if (!maybeLayer) {
  return IPC_FAIL_NO_REASON(this);
}
...

I know it duplicates the IPC_FAIL_NO_REASON bits, but I think this new version is more consistent with Gecko's general fail-fast/less-nesting-preferred coding style.
Attachment #8878912 - Flags: review?(nfroyd) → review+
Comment on attachment 8878913 [details] [diff] [review]
part 2 - Use nsRefPtrHashtable instead of nsDataHashtable with a RefPtr<> data type, since it's clearer and avoids unnecessary AddRef/Release calls

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

Yay for less refcounting!
Attachment #8878913 - Flags: review?(nfroyd) → review+
Pushed by mpalmgren@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/80e602014cf2
part 1 - Use LookupForAdd instead of Contains+Put, and remove an unnecessary Contains call before GetAndRemove, to avoid unnecessary hashtable lookups.  r=froydnj
https://hg.mozilla.org/integration/mozilla-inbound/rev/5d4bb1715f7c
part 2 - Use nsRefPtrHashtable instead of nsDataHashtable with a RefPtr<> data type, since it's clearer and avoids unnecessary AddRef/Release calls.  r=froydnj
https://hg.mozilla.org/mozilla-central/rev/80e602014cf2
https://hg.mozilla.org/mozilla-central/rev/5d4bb1715f7c
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in before you can comment on or make changes to this bug.