RESOLVED FIXED 56312
Web Inspector: Factor out binary search algo from the insertionIndexForObjectInListSortedByFunction function
https://bugs.webkit.org/show_bug.cgi?id=56312
Summary Web Inspector: Factor out binary search algo from the insertionIndexForObject...
Mikhail Naganov
Reported 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.
Attachments
patch (5.28 KB, patch)
2011-03-14 08:21 PDT, Mikhail Naganov
pfeldman: review-
mnaganov: commit-queue-
changed test (5.21 KB, patch)
2011-03-14 08:33 PDT, Mikhail Naganov
pfeldman: review+
mnaganov: commit-queue-
Mikhail Naganov
Comment 1 2011-03-14 08:21:19 PDT
Pavel Feldman
Comment 2 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.
Mikhail Naganov
Comment 3 2011-03-14 08:33:48 PDT
Created attachment 85679 [details] changed test
Pavel Feldman
Comment 4 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.
Mikhail Naganov
Comment 5 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.
Mikhail Naganov
Comment 6 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.
Note You need to log in before you can comment on or make changes to this bug.