Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: avoid protocol registry redundant lookup #41991

Merged
merged 6 commits into from May 9, 2024

Conversation

ckerr
Copy link
Member

@ckerr ckerr commented Apr 29, 2024

Description of Change

Fix a performance wart in ProtocolRegistry. The current workflow is to call ProtocolRegistry::handlers().at(scheme) after a safeguard check to ProtocolRegistry::IsRegistered(scheme). This workflow requires a redundant lookup for scheme and is also a minor demeter violation.

This PR replaces the methods ProtocolRegistry::IsRegistered(scheme) and ProtocolRegistry::handlers(scheme) with a new ProtocolRegistry::FindRegistered(scheme) const that returns a const pointer to the handler, or nullptr if none is found.

Checklist

Release Notes

Notes: none

@ckerr ckerr added performance 🏁 semver/patch backwards-compatible bug fixes no-backport labels Apr 29, 2024
@electron-cation electron-cation bot added new-pr 🌱 PR opened in the last 24 hours and removed new-pr 🌱 PR opened in the last 24 hours labels Apr 29, 2024
@codebytere codebytere self-requested a review May 4, 2024 13:48
ckerr added 6 commits May 8, 2024 21:00
refactor: remove unused ProtocolRegistry::IsProtocolIntercepted()
refactor: rename ProtocolRegistry::FindRegistered()

similar semantics to base::Value::Find*()
chore: use same variable names as in main
@ckerr ckerr force-pushed the perf/avoid-protocol-registry-redundant-lookup branch from 2edeb5b to 7acf7b6 Compare May 9, 2024 02:13
@jkleinsc jkleinsc merged commit e2acdff into main May 9, 2024
15 checks passed
@jkleinsc jkleinsc deleted the perf/avoid-protocol-registry-redundant-lookup branch May 9, 2024 13:53
Copy link

release-clerk bot commented May 9, 2024

No Release Notes

Mrnikifabio pushed a commit to Mrnikifabio/electron that referenced this pull request May 14, 2024
* perf: avoid redundant map lookup in SimpleURLLoaderWrapper::GetURLLoaderFactoryForURL()

* perf: avoid redundant map lookup in InspectableWebContents::LoadNetworkResource()

* refactor: remove unused ProtocolRegistry::IsProtocolRegistered()

refactor: remove unused ProtocolRegistry::IsProtocolIntercepted()

* refactor: remove unused ProtocolRegistry::handlers()

* refactor: rename ProtocolRegistry::FindIntercepted()

refactor: rename ProtocolRegistry::FindRegistered()

similar semantics to base::Value::Find*()

* chore: follow Google C++ brace style

chore: use same variable names as in main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants