WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
118609
Web Inspector: Replace binarySearch with lowerBound and upperBound functions
https://bugs.webkit.org/show_bug.cgi?id=118609
Summary
Web Inspector: Replace binarySearch with lowerBound and upperBound functions
Timothy Hatcher
Reported
2013-07-12 10:40:22 PDT
This allows to avoid index-mapping-to-negative-axis-trick in binarySearch and its usages. It also makes insertionIndexForObjectInListSortedByFunction to work in O(log(n)) time instead of O(n).
https://chromium.googlesource.com/chromium/blink/+/9541aa09240296b72409baf107c38c5efe7004be%5E%21/
Attachments
patch
(15.30 KB, patch)
2014-02-21 00:20 PST
,
Chi Wai Lau
no flags
Details
Formatted Diff
Diff
patch
(14.64 KB, patch)
2014-02-21 14:27 PST
,
Chi Wai Lau
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2013-07-12 10:40:40 PDT
<
rdar://problem/14428765
>
Chi Wai Lau
Comment 2
2014-02-21 00:20:02 PST
Created
attachment 224837
[details]
patch
Timothy Hatcher
Comment 3
2014-02-21 09:30:22 PST
Comment on
attachment 224837
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=224837&action=review
Thanks for fixing this! Can you upload a new patch with these tweaks?
> Source/WebInspectorUI/ChangeLog:5 > + Web Inspector: Replace binarySearch with lowerBound and upperBound functions > +
https://bugs.webkit.org/show_bug.cgi?id=118609
> +
Can you add the reasoning bellow the title? "This makes insertionIndexForObjectInListSortedByFunction work in O(log(n)) time instead of O(n)."
> Source/WebInspectorUI/ChangeLog:13 > + (.): > + (.value): > + (object):
Our script gets confused by Object.defineProperty. Can you manually fix this?
> Source/WebInspectorUI/UserInterface/Utilities.js:939 > + > +
Double new line.
> Source/WebInspectorUI/UserInterface/Utilities.js:946 > + /** > + * Return index of the leftmost element that is equal or greater > + * than the specimen object. If there's no such element (i.e. all > + * elements are smaller than the specimen) returns array.length. > + * The function works for sorted array.
Lets just use // for these comments.
> Source/WebInspectorUI/UserInterface/Utilities.js:951 > + * > + * @this {Array.<*>} > + * @param {*} object > + * @param {function(*,*):number=} comparator > + * @return {number}
We don't use these JSDoc comments. We intend to remove them from our existing code. Lets not add more.
> Source/WebInspectorUI/UserInterface/Utilities.js:979 > + /** > + * Return index of the leftmost element that is greater > + * than the specimen object. If there's no such element (i.e. all > + * elements are smaller than the specimen) returns array.length. > + * The function works for sorted array.
Ditto.
> Source/WebInspectorUI/UserInterface/Utilities.js:984 > + * > + * @this {Array.<*>} > + * @param {*} object > + * @param {function(*,*):number=} comparator > + * @return {number}
Ditto.
> Source/WebInspectorUI/UserInterface/Utilities.js:991 > + function defaultComparator(a, b) > + { > + return a - b; > + }
Lets move this function out next to insertObjectIntoSortedArray, since it can be shared.
> Source/WebInspectorUI/UserInterface/Utilities.js:1013 > + /** > + * @this {Array.<*>} > + * @param {*} value > + * @param {function(*,*):number} comparator > + * @return {number} > + */
Ditto.
> Source/WebInspectorUI/UserInterface/Utilities.js:1027 > +/** > + * @param {*} object > + * @param {Array.<*>} list > + * @param {function(*,*):number=} comparator > + * @param {boolean=} insertionIndexAfter > + * @return {number} > + */
Ditto.
> Source/WebInspectorUI/UserInterface/Utilities.js:1041 > +/** > + * @param {*} object > + * @param {Array.<*>} array > + * @param {function(*,*):number=} comparator > + */
Ditto.
Chi Wai Lau
Comment 4
2014-02-21 14:27:40 PST
Created
attachment 224909
[details]
patch
Timothy Hatcher
Comment 5
2014-02-21 15:02:35 PST
Comment on
attachment 224909
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=224909&action=review
> LayoutTests/ChangeLog:9 > + * inspector/utilities-expected.txt: > + * inspector/utilities.html:
These tests are not run anymore and are being removed in
bug 129168
.
WebKit Commit Bot
Comment 6
2014-02-21 16:05:33 PST
Comment on
attachment 224909
[details]
patch Clearing flags on attachment: 224909 Committed
r164512
: <
http://trac.webkit.org/changeset/164512
>
WebKit Commit Bot
Comment 7
2014-02-21 16:05:36 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.
Top of Page
Format For Printing
XML
Clone This Bug