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

Unified Diff: third_party/WebKit/Source/devtools/front_end/platform/utilities.js

Issue 1809533003: DevTools: remove illusionary caching from String.prototype.lineEndings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/platform/utilities.js
diff --git a/third_party/WebKit/Source/devtools/front_end/platform/utilities.js b/third_party/WebKit/Source/devtools/front_end/platform/utilities.js
index 803caaf1eeae8a5370ced9c636ce15618ecc11cd..8c5f74e0d81c5c0e778b6cbeb403b337630661ea 100644
--- a/third_party/WebKit/Source/devtools/front_end/platform/utilities.js
+++ b/third_party/WebKit/Source/devtools/front_end/platform/utilities.js
@@ -114,44 +114,9 @@ String.prototype.isWhitespace = function()
*/
String.prototype.lineEndings = function()
dgozman 2016/03/16 20:36:48 Why don't we remove this method?
lushnikov 2016/03/16 21:04:01 It still comes handy in formatter worker.
{
- if (!this._lineEndings) {
- this._lineEndings = this.findAll("\n");
- this._lineEndings.push(this.length);
- }
- return this._lineEndings;
-}
-
-/**
- * @return {number}
- */
-String.prototype.lineCount = function()
-{
- var lineEndings = this.lineEndings();
- return lineEndings.length;
-}
-
-/**
- * @param {number} lineNumber
- * @param {number} columNumber
- * @return {number}
- */
-String.prototype.offsetFromPosition = function(lineNumber, columNumber)
-{
- return (lineNumber ? this.lineEndings()[lineNumber - 1] + 1 : 0) + columNumber;
-}
-
-/**
- * @return {string}
- */
-String.prototype.lineAt = function(lineNumber)
-{
- var lineEndings = this.lineEndings();
- var lineStart = lineNumber > 0 ? lineEndings[lineNumber - 1] + 1 : 0;
- var lineEnd = lineEndings[lineNumber];
- var lineContent = this.substring(lineStart, lineEnd);
- if (lineContent.length > 0 && lineContent.charAt(lineContent.length - 1) === "\r")
- lineContent = lineContent.substring(0, lineContent.length - 1);
- return lineContent;
+ var endings = this.findAll("\n");
+ endings.push(this.length);
+ return endings;
}
/**

Powered by Google App Engine
This is Rietveld 408576698