Skip to content

Commit

Permalink
perf: use string comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Aug 4, 2024
1 parent 36f24d3 commit a2a03bf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ const escapeFunction = (string) => {
let start = 0;

for (let end = 0; end !== string.length; ++end) {
switch (string.charCodeAt(end)) {
case 34: // "
switch (string[end]) {
case '"':
escaped += string.slice(start, end) + """;
start = end + 1;
continue;
case 38: // &
case "&":
escaped += string.slice(start, end) + "&";
start = end + 1;
continue;
case 39: // '
case "'":
escaped += string.slice(start, end) + "'";
start = end + 1;
continue;
case 60: // <
case "<":
escaped += string.slice(start, end) + "&#60;";
start = end + 1;
continue;
case 61: // =
case "=":
escaped += string.slice(start, end) + "&#61;";
start = end + 1;
continue;
case 62: // >
case ">":
escaped += string.slice(start, end) + "&#62;";
start = end + 1;
continue;
Expand Down

0 comments on commit a2a03bf

Please # to comment.