Bug 124374

Summary: Web Inspector: Simply generated domain dispatch methods for domains with few commands
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, graouts, joepeck, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Proposed Fix none

Joseph Pecoraro
Reported 2013-11-14 12:07:59 PST
A bunch of domains have only a few methods. The hash lookup does not make sense. Turn: void InspectorInspectorBackendDispatcher::dispatch(long callId, const String& method, PassRefPtr<InspectorObject> message) { Ref<InspectorInspectorBackendDispatcher> protect(*this); typedef void (InspectorInspectorBackendDispatcher::*CallHandler)(long callId, const InspectorObject& message); typedef HashMap<String, CallHandler> DispatchMap; DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, ()); if (dispatchMap.isEmpty()) { static const struct MethodTable { const char* name; CallHandler handler; } commands[] = { { "enable", &InspectorInspectorBackendDispatcher::enable }, { "disable", &InspectorInspectorBackendDispatcher::disable }, }; size_t length = WTF_ARRAY_LENGTH(commands); for (size_t i = 0; i < length; ++i) dispatchMap.add(commands[i].name, commands[i].handler); } HashMap<String, CallHandler>::iterator it = dispatchMap.find(method); if (it == dispatchMap.end()) { m_backendDispatcher->reportProtocolError(&callId, InspectorBackendDispatcher::MethodNotFound, String("'") + "Inspector" + '.' + method + "' was not found"); return; } ((*this).*it->value)(callId, *message.get()); } into: void InspectorInspectorBackendDispatcher::dispatch(long callId, const String& method, PassRefPtr<InspectorObject> message) { Ref<InspectorInspectorBackendDispatcher> protect(*this); if (method == "enable") enable(callId, *message.get()); else if (method == "disable") disable(callId, *message.get()); else m_backendDispatcher->reportProtocolError(&callId, InspectorBackendDispatcher::MethodNotFound, String("'") + "Inspector" + '.' + method + "' was not found"); }
Attachments
[PATCH] Proposed Fix (6.41 KB, patch)
2013-11-14 12:20 PST, Joseph Pecoraro
no flags
Radar WebKit Bug Importer
Comment 1 2013-11-14 12:08:30 PST
Joseph Pecoraro
Comment 2 2013-11-14 12:20:03 PST
Created attachment 216967 [details] [PATCH] Proposed Fix
WebKit Commit Bot
Comment 3 2013-11-14 13:28:37 PST
Comment on attachment 216967 [details] [PATCH] Proposed Fix Clearing flags on attachment: 216967 Committed r159308: <http://trac.webkit.org/changeset/159308>
WebKit Commit Bot
Comment 4 2013-11-14 13:28:38 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.