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

Unified Diff: src/messages.js

Issue 434117: Remove usage of JSArray in Script object... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/handles.cc ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/messages.js
===================================================================
--- src/messages.js (revision 3373)
+++ src/messages.js (working copy)
@@ -238,14 +238,15 @@
Script.prototype.lineFromPosition = function(position) {
var lower = 0;
var upper = this.lineCount() - 1;
+ var line_ends = this.line_ends;
// We'll never find invalid positions so bail right away.
- if (position > this.line_ends[upper]) {
+ if (position > line_ends[upper]) {
return -1;
}
// This means we don't have to safe-guard indexing line_ends[i - 1].
- if (position <= this.line_ends[0]) {
+ if (position <= line_ends[0]) {
return 0;
}
@@ -253,9 +254,9 @@
while (upper >= 1) {
var i = (lower + upper) >> 1;
- if (position > this.line_ends[i]) {
+ if (position > line_ends[i]) {
lower = i + 1;
- } else if (position <= this.line_ends[i - 1]) {
+ } else if (position <= line_ends[i - 1]) {
upper = i - 1;
} else {
return i;
@@ -278,8 +279,9 @@
if (line == -1) return null;
// Determine start, end and column.
- var start = line == 0 ? 0 : this.line_ends[line - 1] + 1;
- var end = this.line_ends[line];
+ var line_ends = this.line_ends;
+ var start = line == 0 ? 0 : line_ends[line - 1] + 1;
+ var end = line_ends[line];
if (end > 0 && StringCharAt.call(this.source, end - 1) == '\r') end--;
var column = position - start;
@@ -368,8 +370,9 @@
return null;
}
- var from_position = from_line == 0 ? 0 : this.line_ends[from_line - 1] + 1;
- var to_position = to_line == 0 ? 0 : this.line_ends[to_line - 1] + 1;
+ var line_ends = this.line_ends;
+ var from_position = from_line == 0 ? 0 : line_ends[from_line - 1] + 1;
+ var to_position = to_line == 0 ? 0 : line_ends[to_line - 1] + 1;
// Return a source slice with line numbers re-adjusted to the resource.
return new SourceSlice(this, from_line + this.line_offset, to_line + this.line_offset,
@@ -391,8 +394,9 @@
}
// Return the source line.
- var start = line == 0 ? 0 : this.line_ends[line - 1] + 1;
- var end = this.line_ends[line];
+ var line_ends = this.line_ends;
+ var start = line == 0 ? 0 : line_ends[line - 1] + 1;
+ var end = line_ends[line];
return StringSubstring.call(this.source, start, end);
}
« no previous file with comments | « src/handles.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698