Bug 31699 - Web Inspector: Should Cache Values of InspectorController.platform() and port
Summary: Web Inspector: Should Cache Values of InspectorController.platform() and port
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Brian Weinstein
URL:
Keywords:
Depends on:
Blocks: 31700
  Show dependency treegraph
 
Reported: 2009-11-19 18:58 PST by Brian Weinstein
Modified: 2009-11-20 10:43 PST (History)
7 users (show)

See Also:


Attachments
[PATCH] Fix (7.06 KB, patch)
2009-11-19 18:59 PST, Brian Weinstein
bweinstein: commit-queue-
Details | Formatted Diff | Diff
[PATCH] Use getters instead of WebInspector.function (7.02 KB, patch)
2009-11-19 19:10 PST, Brian Weinstein
timothy: review+
bweinstein: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Weinstein 2009-11-19 18:58:02 PST
These functions have to call into C++, they are being used more and more (keyboard shortcuts need to call it), and the values shouldn't change.
Comment 1 Brian Weinstein 2009-11-19 18:59:48 PST
Created attachment 43539 [details]
[PATCH] Fix
Comment 2 Brian Weinstein 2009-11-19 19:10:50 PST
Created attachment 43540 [details]
[PATCH] Use getters instead of WebInspector.function
Comment 3 Timothy Hatcher 2009-11-19 20:36:25 PST
Comment on attachment 43540 [details]
[PATCH] Use getters instead of WebInspector.function

> +        if (!this._platform)

A better idiom we use is:

          if (!("_platform" in this))

It is semi faster. It only checks if the property exists, not the value.

> +        if (!this._port)

Ditto.
Comment 4 Pavel Feldman 2009-11-19 21:49:42 PST
Given that we are 100% sure platform and port are needed for rendering, it does not really make sense to load them lazily. I'd rather push them into the frontend as soon as script object for it is available. Furthermore, I think we should do the same to inspector settings. Generic approach would be to create Preferences object (the one from inspector.js or its override) in InspectorController and push it into the frontend from within InspectorController::scriptObjectReady.
Comment 5 Patrick Mueller 2009-11-20 04:03:21 PST
(In reply to comment #4)
> I think we
> should do the same to inspector settings. Generic approach would be to create
> Preferences object (the one from inspector.js or its override) in
> InspectorController and push it into the frontend from within
> InspectorController::scriptObjectReady.

I didn't realize we already had a Preferences object; sounds like a good place to put the pre-load of the settings from InspectorController.  Do we create a method per setting, or two - a getter and setter - or a generic getter and setter?

Even though it gets busy, I like having method-per-setting, because then it's easy to figure out what all the possible settings actually are.
Comment 6 Pavel Feldman 2009-11-20 04:55:37 PST
(In reply to comment #5)
> (In reply to comment #4)
> > I think we
> > should do the same to inspector settings. Generic approach would be to create
> > Preferences object (the one from inspector.js or its override) in
> > InspectorController and push it into the frontend from within
> > InspectorController::scriptObjectReady.
> 
> I didn't realize we already had a Preferences object; sounds like a good place
> to put the pre-load of the settings from InspectorController.  Do we create a
> method per setting, or two - a getter and setter - or a generic getter and
> setter?
> 
> Even though it gets busy, I like having method-per-setting, because then it's
> easy to figure out what all the possible settings actually are.

I think we should have named settings with shared getter and single setter in order not to bloat cache-related code. We could have constants for names of the known settings to address your argument.
Comment 7 Brian Weinstein 2009-11-20 10:32:50 PST
(In reply to comment #4)
> Given that we are 100% sure platform and port are needed for rendering, it does
> not really make sense to load them lazily. I'd rather push them into the
> frontend as soon as script object for it is available. Furthermore, I think we
> should do the same to inspector settings. Generic approach would be to create
> Preferences object (the one from inspector.js or its override) in
> InspectorController and push it into the frontend from within
> InspectorController::scriptObjectReady.

I'm going to land this optimization in the patch, because it will clean up code a good amount, but if we want to figure out future optimizations (like not loading this lazily), we can do that in the future.
Comment 8 Brian Weinstein 2009-11-20 10:43:24 PST
Landed in r51242.