Summary: | Web Inspector: Eliminate unnecessary hash lookups with NetworkResourceData | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Joseph Pecoraro <joepeck> | ||||||
Component: | Web Inspector | Assignee: | Joseph Pecoraro <joepeck> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | bburg, buildbot, commit-queue, inspector-bugzilla-changes, joepeck, sam, webkit-bug-importer | ||||||
Priority: | P2 | Keywords: | InRadar | ||||||
Version: | WebKit Nightly Build | ||||||||
Hardware: | All | ||||||||
OS: | All | ||||||||
Attachments: |
|
Description
Joseph Pecoraro
2017-11-06 19:54:27 PST
Created attachment 326187 [details]
[PATCH] Proposed Fix
Comment on attachment 326187 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=326187&action=review > Source/WebCore/inspector/NetworkResourcesData.cpp:131 > + auto* resourceData = new ResourceData(requestId, loaderId); > + resourceData->setType(type); > + m_requestIdToResourceDataMap.set(requestId, resourceData); An additional cleanup that you might want to do is change m_requestIdToResourceDataMap to store a std::unique_ptr rather than a raw ptr for its value. > Source/WebCore/inspector/NetworkResourcesData.cpp:134 > +void NetworkResourcesData::resourceCreated(const String& requestId, const String& loaderId, CachedResource* cachedResource) Can this take the CachedResource by reference? > Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:351 > + String loaderId = m_pageAgent->loaderId(&loader); Can use auto. > Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:444 > + String frameId = m_pageAgent->frameId(loader.frame()); > + String loaderId = m_pageAgent->loaderId(&loader); Can use auto. > Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:531 > + String loaderId = m_pageAgent->loaderId(&loader); > + String frameId = m_pageAgent->frameId(loader.frame()); Can use auto. Comment on attachment 326187 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=326187&action=review >> Source/WebCore/inspector/NetworkResourcesData.cpp:131 >> + m_requestIdToResourceDataMap.set(requestId, resourceData); > > An additional cleanup that you might want to do is change m_requestIdToResourceDataMap to store a std::unique_ptr rather than a raw ptr for its value. This is an excellent idea, I should have addressed this in this change anyways instead of allowing `new` / `delete` in our code. I'll put up a new patch. >> Source/WebCore/inspector/NetworkResourcesData.cpp:134 >> +void NetworkResourcesData::resourceCreated(const String& requestId, const String& loaderId, CachedResource* cachedResource) > > Can this take the CachedResource by reference? Yep. (In reply to Joseph Pecoraro from comment #0) > Eliminate unnecessary hash lookups with NetworkResourceData > > There are a few places where we do multiple hash lookups on > NetworkResourceData that we don't need: Another multiple-hash-lookup we can remove is: ensureNoDataForRequestId ResourceData* resourceData = resourceDataForRequestId(requestId); ... m_requestIdToResourceDataMap.remove(requestId); Created attachment 326233 [details]
[PATCH] Proposed Fix
Attachment 326233 [details] did not pass style-queue:
ERROR: Source/WebCore/inspector/NetworkResourcesData.cpp:273: More than one command on the same line [whitespace/newline] [4]
Total errors found: 1 in 4 files
If any of these errors are false positives, please file a bug against check-webkit-style.
Comment on attachment 326233 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=326233&action=review r=me > Source/WebCore/inspector/NetworkResourcesData.cpp:266 > + return entry.value->loaderId() != loaderId; v. cool Comment on attachment 326233 [details] [PATCH] Proposed Fix Clearing flags on attachment: 326233 Committed r224596: <https://trac.webkit.org/changeset/224596> All reviewed patches have been landed. Closing bug. |