diff options
author | Matt Godbolt <matt@godbolt.org> | 2019-03-21 21:28:43 -0500 |
---|---|---|
committer | Matt Godbolt <matt@godbolt.org> | 2019-03-21 21:28:43 -0500 |
commit | 2e7fc5fe80bd8f616897d558e1f3b04a95e3943f (patch) | |
tree | f5e470e4e01dd2624c74415bbc639666835b795c /lib/utils.js | |
parent | 43e24cb00d13cd443c34b27c67ec76cbe96b37fd (diff) | |
download | compiler-explorer-2e7fc5fe80bd8f616897d558e1f3b04a95e3943f.tar.gz compiler-explorer-2e7fc5fe80bd8f616897d558e1f3b04a95e3943f.zip |
Super minor tweaks to @bugwelle's awesome PR for LLVM IR mode!
Diffstat (limited to 'lib/utils.js')
-rw-r--r-- | lib/utils.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/utils.js b/lib/utils.js index 585c4fced..69e2b78bc 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -90,7 +90,7 @@ exports.padRight = padRight; function trimRight(name) { var l = name.length; - while (l > 0 && name[l-1] === ' ') l -= 1; + while (l > 0 && name[l - 1] === ' ') l -= 1; return name.substr(0, l); } @@ -107,8 +107,7 @@ exports.trimRight = trimRight; exports.anonymizeIp = function anonymizeIp(ip) { if (ip.includes('localhost')) { return ip; - } - else if (ip.includes(':')) { + } else if (ip.includes(':')) { // IPv6 return ip.replace(/:[\da-fA-F]{0,4}:[\da-fA-F]{0,4}:[\da-fA-F]{0,4}$/, ':0:0:0'); } else { @@ -119,7 +118,7 @@ exports.anonymizeIp = function anonymizeIp(ip) { function objectToHashableString(object) { // See https://stackoverflow.com/questions/899574/which-is-best-to-use-typeof-or-instanceof/6625960#6625960 - return (typeof(object) === 'string') ? object : JSON.stringify(object); + return (typeof (object) === 'string') ? object : JSON.stringify(object); } const DefaultHash = 'Compiler Explorer Default Version 1'; @@ -177,12 +176,13 @@ exports.glGetMainContents = function glGetMainContents(content) { return contents; }; -function trimLine(line) { +function squashHorizontalWhitespace(line, atStart) { + if (atStart === undefined) atStart = true; if (!line.trim().length) { return ""; } const splat = line.split(/\s+/); - if (splat[0] === "") { + if (splat[0] === "" && atStart) { // An indented line: preserve a two-space indent (max) const intent = line[1] !== " " ? " " : " "; return intent + splat.slice(1).join(" "); @@ -190,4 +190,4 @@ function trimLine(line) { return splat.join(" "); } -exports.trimLine = trimLine; +exports.squashHorizontalWhitespace = squashHorizontalWhitespace; |