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

Side by Side Diff: Source/devtools/front_end/platform/utilities.js

Issue 1310303004: [DevTools] Reduce amount of tokens produced by tokenizeFormatString (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | 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 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 * @param {!Object.<string, function(string, ...):*>} formatters 952 * @param {!Object.<string, function(string, ...):*>} formatters
953 * @return {!Array.<!Object>} 953 * @return {!Array.<!Object>}
954 */ 954 */
955 String.tokenizeFormatString = function(format, formatters) 955 String.tokenizeFormatString = function(format, formatters)
956 { 956 {
957 var tokens = []; 957 var tokens = [];
958 var substitutionIndex = 0; 958 var substitutionIndex = 0;
959 959
960 function addStringToken(str) 960 function addStringToken(str)
961 { 961 {
962 tokens.push({ type: "string", value: str }); 962 if (tokens.length && tokens[tokens.length - 1].type === "string")
963 tokens[tokens.length - 1].value += str;
964 else
965 tokens.push({ type: "string", value: str });
963 } 966 }
964 967
965 function addSpecifierToken(specifier, precision, substitutionIndex) 968 function addSpecifierToken(specifier, precision, substitutionIndex)
966 { 969 {
967 tokens.push({ type: "specifier", specifier: specifier, precision: precis ion, substitutionIndex: substitutionIndex }); 970 tokens.push({ type: "specifier", specifier: specifier, precision: precis ion, substitutionIndex: substitutionIndex });
968 } 971 }
969 972
970 var index = 0; 973 var index = 0;
971 for (var precentIndex = format.indexOf("%", index); precentIndex !== -1; pre centIndex = format.indexOf("%", index)) { 974 for (var precentIndex = format.indexOf("%", index); precentIndex !== -1; pre centIndex = format.indexOf("%", index)) {
972 if (format.length === index) // unescaped % sign at the end of the form at string. 975 if (format.length === index) // unescaped % sign at the end of the form at string.
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 * @param {T} defaultValue 1492 * @param {T} defaultValue
1490 * @return {!Promise.<T>} 1493 * @return {!Promise.<T>}
1491 * @template T 1494 * @template T
1492 */ 1495 */
1493 Promise.prototype.catchException = function(defaultValue) { 1496 Promise.prototype.catchException = function(defaultValue) {
1494 return this.catch(function (error) { 1497 return this.catch(function (error) {
1495 console.error(error); 1498 console.error(error);
1496 return defaultValue; 1499 return defaultValue;
1497 }); 1500 });
1498 } 1501 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698