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

Side by Side Diff: tracing/tracing/extras/importer/trace_code_map.html

Issue 2776653002: [ESLint] Fix violations when enabling curly rule in eslint. (Closed)
Patch Set: rebase Created 3 years, 8 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2015 The Chromium Authors. All rights reserved. 3 Copyright 2015 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel='import' href='/tracing/extras/importer/trace_code_entry.html'> 8 <link rel='import' href='/tracing/extras/importer/trace_code_entry.html'>
9 9
10 <script> 10 <script>
(...skipping 10 matching lines...) Expand all
21 addEntry: function(addressHex, size, name, scriptId) { 21 addEntry: function(addressHex, size, name, scriptId) {
22 var entry = new tr.e.importer.TraceCodeEntry( 22 var entry = new tr.e.importer.TraceCodeEntry(
23 this.getAddress_(addressHex), size, name, scriptId); 23 this.getAddress_(addressHex), size, name, scriptId);
24 24
25 this.addEntry_(addressHex, entry); 25 this.addEntry_(addressHex, entry);
26 }, 26 },
27 27
28 moveEntry: function(oldAddressHex, newAddressHex, size) { 28 moveEntry: function(oldAddressHex, newAddressHex, size) {
29 var entry = this.getBank_(oldAddressHex) 29 var entry = this.getBank_(oldAddressHex)
30 .removeEntry(this.getAddress_(oldAddressHex)); 30 .removeEntry(this.getAddress_(oldAddressHex));
31 if (!entry) 31 if (!entry) return;
32 return;
33 32
34 entry.address = this.getAddress_(newAddressHex); 33 entry.address = this.getAddress_(newAddressHex);
35 entry.size = size; 34 entry.size = size;
36 this.addEntry_(newAddressHex, entry); 35 this.addEntry_(newAddressHex, entry);
37 }, 36 },
38 37
39 lookupEntry: function(addressHex) { 38 lookupEntry: function(addressHex) {
40 return this.getBank_(addressHex) 39 return this.getBank_(addressHex)
41 .lookupEntry(this.getAddress_(addressHex)); 40 .lookupEntry(this.getAddress_(addressHex));
42 }, 41 },
(...skipping 27 matching lines...) Expand all
70 }; 69 };
71 70
72 function TraceCodeBank() { 71 function TraceCodeBank() {
73 this.entries_ = []; 72 this.entries_ = [];
74 } 73 }
75 74
76 TraceCodeBank.prototype = { 75 TraceCodeBank.prototype = {
77 removeEntry: function(address) { 76 removeEntry: function(address) {
78 // findLowIndexInSortedArray returns 1 for empty. Just handle the 77 // findLowIndexInSortedArray returns 1 for empty. Just handle the
79 // empty list and bail early. 78 // empty list and bail early.
80 if (this.entries_.length === 0) 79 if (this.entries_.length === 0) return undefined;
81 return undefined;
82 80
83 var index = tr.b.math.findLowIndexInSortedArray( 81 var index = tr.b.math.findLowIndexInSortedArray(
84 this.entries_, function(entry) { return entry.address; }, address); 82 this.entries_, function(entry) { return entry.address; }, address);
85 var entry = this.entries_[index]; 83 var entry = this.entries_[index];
86 if (!entry || entry.address !== address) 84 if (!entry || entry.address !== address) return undefined;
87 return undefined;
88 85
89 this.entries_.splice(index, 1); 86 this.entries_.splice(index, 1);
90 return entry; 87 return entry;
91 }, 88 },
92 89
93 lookupEntry: function(address) { 90 lookupEntry: function(address) {
94 var index = tr.b.math.findHighIndexInSortedArray( 91 var index = tr.b.math.findHighIndexInSortedArray(
95 this.entries_, function(e) { return address - e.address; }) - 1; 92 this.entries_, function(e) { return address - e.address; }) - 1;
96 var entry = this.entries_[index]; 93 var entry = this.entries_[index];
97 return entry && 94 return entry &&
98 address < entry.address + entry.size ? entry : undefined; 95 address < entry.address + entry.size ? entry : undefined;
99 }, 96 },
100 97
101 addEntry: function(newEntry) { 98 addEntry: function(newEntry) {
102 // findLowIndexInSortedArray returns 1 for empty list. Just push the 99 // findLowIndexInSortedArray returns 1 for empty list. Just push the
103 // new address as it's the only item. 100 // new address as it's the only item.
104 if (this.entries_.length === 0) 101 if (this.entries_.length === 0) {
105 this.entries_.push(newEntry); 102 this.entries_.push(newEntry);
103 }
106 104
107 var endAddress = newEntry.address + newEntry.size; 105 var endAddress = newEntry.address + newEntry.size;
108 var lastIndex = tr.b.math.findLowIndexInSortedArray( 106 var lastIndex = tr.b.math.findLowIndexInSortedArray(
109 this.entries_, function(entry) { return entry.address; }, endAddress); 107 this.entries_, function(entry) { return entry.address; }, endAddress);
110 var index; 108 var index;
111 for (index = lastIndex - 1; index >= 0; --index) { 109 for (index = lastIndex - 1; index >= 0; --index) {
112 var entry = this.entries_[index]; 110 var entry = this.entries_[index];
113 var entryEndAddress = entry.address + entry.size; 111 var entryEndAddress = entry.address + entry.size;
114 if (entryEndAddress <= newEntry.address) 112 if (entryEndAddress <= newEntry.address) break;
115 break;
116 } 113 }
117 ++index; 114 ++index;
118 this.entries_.splice(index, lastIndex - index, newEntry); 115 this.entries_.splice(index, lastIndex - index, newEntry);
119 } 116 }
120 }; 117 };
121 118
122 return { 119 return {
123 TraceCodeMap, 120 TraceCodeMap,
124 }; 121 };
125 }); 122 });
126 123
127 </script> 124 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698