Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: tools/turbolizer/util.js

Issue 2050233002: [turbolizer] Add 2 buttons; add middle-click on input; add comment in UI. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@mywork
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/turbolizer/index.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 "use strict"; 5 "use strict";
6 6
7 function makeContainerPosVisible(container, pos) { 7 function makeContainerPosVisible(container, pos) {
8 var height = container.offsetHeight; 8 var height = container.offsetHeight;
9 var margin = Math.floor(height / 4); 9 var margin = Math.floor(height / 4);
10 if (pos < container.scrollTop + margin) { 10 if (pos < container.scrollTop + margin) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 function sortUnique(arr, f) { 62 function sortUnique(arr, f) {
63 arr = arr.sort(f); 63 arr = arr.sort(f);
64 let ret = [arr[0]]; 64 let ret = [arr[0]];
65 for (var i = 1; i < arr.length; i++) { 65 for (var i = 1; i < arr.length; i++) {
66 if (arr[i-1] !== arr[i]) { 66 if (arr[i-1] !== arr[i]) {
67 ret.push(arr[i]); 67 ret.push(arr[i]);
68 } 68 }
69 } 69 }
70 return ret; 70 return ret;
71 } 71 }
72
73 // Find elements in the array that match a filter. Apply an action on each
74 // such element. Check if new elements match the filter; apply the action to
75 // those elements. Repeat until no new elements match the filter and the
76 // action has been called at least once on elements that match the filter.
77 //
78 // The filter should not have any side effects. Any elements that match the
79 // filter should continue to match the filter, regardless of calls to the
80 // action on arbitrary elements.
81 //
82 // Returns nothing.
83 function filterActionUntilStabilize(arr, filt, action) {
84
85 var elementsLeft = arr.slice(); // shallow copy
86
87 while (true) {
88 var matching = [];
89 var nonMatching = [];
90
91 elementsLeft.forEach(function(element) {
92 if (filt(element)) {
93 matching.push(element);
94 action(element);
95 } else {
96 nonMatching.push(element);
97 }
98 });
99
100 if (elementsLeft.length == nonMatching.length) {
101 // We stabilized; exit.
102 break;
103 } else {
104 // Some elements matched and we called the action. It is possible that
105 // elements that never matched the filter, will match it on the next
106 // iteration.
107 elementsLeft = nonMatching;
108 continue;
109 }
110 }
111 }
OLDNEW
« no previous file with comments | « tools/turbolizer/index.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698