Bug 56312 - Web Inspector: Factor out binary search algo from the insertionIndexForObjectInListSortedByFunction function
Summary: Web Inspector: Factor out binary search algo from the insertionIndexForObject...
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: Mikhail Naganov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-14 08:17 PDT by Mikhail Naganov
Modified: 2011-03-24 06:04 PDT (History)
10 users (show)

See Also:


Attachments
patch (5.28 KB, patch)
2011-03-14 08:21 PDT, Mikhail Naganov
pfeldman: review-
mnaganov: commit-queue-
Details | Formatted Diff | Diff
changed test (5.21 KB, patch)
2011-03-14 08:33 PDT, Mikhail Naganov
pfeldman: review+
mnaganov: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Naganov 2011-03-14 08:17:55 PDT
I was looking for binary search implementation in Inspector, and found this funny-named function. It actually does more than binary search, so I factored out BS out from it.
I added 'binaryIndexOf(value, comparator)' function to Array prototype.
Comment 1 Mikhail Naganov 2011-03-14 08:21:19 PDT
Created attachment 85676 [details]
patch
Comment 2 Pavel Feldman 2011-03-14 08:25:30 PDT
Comment on attachment 85676 [details]
patch

Looks good except for the test. We don't use initialize_ prefix in the tests.
Comment 3 Mikhail Naganov 2011-03-14 08:33:48 PDT
Created attachment 85679 [details]
changed test
Comment 4 Pavel Feldman 2011-03-14 08:46:54 PDT
Comment on attachment 85679 [details]
changed test

View in context: https://bugs.webkit.org/attachment.cgi?id=85679&action=review

> LayoutTests/inspector/utilities.html:8
> +    function BinaryIndexOfTest()

start with lowerCase.

> LayoutTests/inspector/utilities.html:19
> +        function TestArray(array)

lowerCase.

> LayoutTests/inspector/utilities.html:21
> +            function Comparator(a, b)

lowerCase

> LayoutTests/inspector/utilities.html:49
> +    BinaryIndexOfTest();

No need to declare and run - simply inline.
Comment 5 Mikhail Naganov 2011-03-14 09:01:40 PDT
(In reply to comment #4)
> (From update of attachment 85679 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=85679&action=review
> 
> > LayoutTests/inspector/utilities.html:8
> > +    function BinaryIndexOfTest()
> 
> start with lowerCase.
> 

Done.

> > LayoutTests/inspector/utilities.html:19
> > +        function TestArray(array)
> 
> lowerCase.
> 

Done.

> > LayoutTests/inspector/utilities.html:21
> > +            function Comparator(a, b)
> 
> lowerCase
> 

Done.

> > LayoutTests/inspector/utilities.html:49
> > +    BinaryIndexOfTest();
> 
> No need to declare and run - simply inline.


Done.
Comment 6 Mikhail Naganov 2011-03-24 06:04:30 PDT
Committed manually http://trac.webkit.org/changeset/81029

Web Inspector: Factor out binary search algo from the insertionIndexForObjectInListSortedByFunction function.
https://bugs.webkit.org/show_bug.cgi?id=56312

Test: inspector/utilities.html
inspector/front-end/utilities.js:
inspector/utilities-expected.txt: Added.
inspector/utilities.html: Added.