WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
137190
Web Inspector: InspectorValues should use references for out parameters
https://bugs.webkit.org/show_bug.cgi?id=137190
Summary
Web Inspector: InspectorValues should use references for out parameters
Brian Burg
Reported
2014-09-28 00:33:59 PDT
We never check for null, so...
Attachments
Patch
(82.29 KB, patch)
2014-09-28 14:40 PDT
,
Brian Burg
joepeck
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2014-09-28 00:34:08 PDT
<
rdar://problem/18480915
>
Brian Burg
Comment 2
2014-09-28 14:40:11 PDT
Created
attachment 238822
[details]
Patch
WebKit Commit Bot
Comment 3
2014-09-28 14:41:48 PDT
This patch modifies the inspector protocol generator. Please ensure that you have rebaselined any generator test results (i.e., by running `Tools/Scripts/run-inspector-generator-tests --reset-results`)
Joseph Pecoraro
Comment 4
2014-09-29 13:15:43 PDT
Comment on
attachment 238822
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=238822&action=review
r=me
> Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp:229 > + static bool asInteger(InspectorValue& value, int& output) { return value.asInteger(output); } > + static bool asDouble(InspectorValue& value, double& output) { return value.asDouble(output); } > + static bool asString(InspectorValue& value, String& output) { return value.asString(output); } > + static bool asBoolean(InspectorValue& value, bool& output) { return value.asBoolean(output); } > + static bool asObject(InspectorValue& value, RefPtr<InspectorObject>& output) { return value.asObject(output); } > + static bool asArray(InspectorValue& value, RefPtr<InspectorArray>& output) { return value.asArray(output); }
Nit: "const" InspectorValue& value
> Source/JavaScriptCore/inspector/InspectorValues.cpp:334 > + output = "";
Nit: We should use String() or emptyString() instead of "".
> Source/JavaScriptCore/inspector/InspectorValues.cpp:684 > + output.append(trueString, 4);
I think we can change all of these append(const char*, unsigned) into appendLiteral(const char*). Which will have the compiler computer the length and call append(const char*, unsigned) for us. But that could be done separately.
> Source/JavaScriptCore/inspector/InspectorValues.cpp:765 > + return result;
Nit: .release()
> Source/JavaScriptCore/inspector/InspectorValues.cpp:776 > + return result;
Nit: .release()
> Source/JavaScriptCore/inspector/InspectorValues.h:87 > + static bool parseJSON(const String& jsonInput, RefPtr<InspectorValue>& output);
I liked the original parseJSON just fine. This seems fine though. Do you see an advantage?
> Source/WebCore/inspector/InspectorIndexedDBAgent.cpp:340 > if (type == number) { > double number; > - if (!key->getDouble("number", &number)) > + if (!key->getDouble("number", number))
I don't like the shadowing of variables. outer scope: NeverDestroyed<const String> number(ASCIILiteral("number")); inner scope: double number; But you are not changing this.
Brian Burg
Comment 5
2014-09-29 14:16:03 PDT
Comment on
attachment 238822
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=238822&action=review
>> Source/JavaScriptCore/inspector/InspectorValues.cpp:334 >> + output = ""; > > Nit: We should use String() or emptyString() instead of "".
OK. (My next plan was to make ErrorString everywhere a reference, but this would of course completely clash with this patch)
>> Source/JavaScriptCore/inspector/InspectorValues.cpp:684 >> + output.append(trueString, 4); > > I think we can change all of these append(const char*, unsigned) into appendLiteral(const char*). Which will have the compiler computer the length and call append(const char*, unsigned) for us. But that could be done separately.
had never thought of it, but sure!
>> Source/JavaScriptCore/inspector/InspectorValues.h:87 >> + static bool parseJSON(const String& jsonInput, RefPtr<InspectorValue>& output); > > I liked the original parseJSON just fine. This seems fine though. Do you see an advantage?
I prefer the slightly more cumbersome outparam approach, because it forces callers to handle parse failure (or look suspicious not doing so). This patch standardizes on that pattern (for object and array casts/gets, too).
>> Source/WebCore/inspector/InspectorIndexedDBAgent.cpp:340 >> + if (!key->getDouble("number", number)) > > I don't like the shadowing of variables. > > outer scope: NeverDestroyed<const String> number(ASCIILiteral("number")); > inner scope: double number; > > But you are not changing this.
yuck, i'll rename the literals.
Brian Burg
Comment 6
2014-09-29 20:30:57 PDT
Committed
r174094
: <
http://trac.webkit.org/changeset/174094
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug