Skip to content

Commit

Permalink
JSON: Regexp optimisation + don't use captures if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Oct 22, 2017
1 parent a491f9e commit 8fc1b03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions components/prism-json.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Prism.languages.json = {
'property': /"(?:\\.|[^\\"])*"(?=\s*:)/ig,
'property': /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,
'string': {
pattern: /"(?:\\.|[^\\"])*"(?!:)/g,
pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
greedy: true
},
'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?)\b/g,
'punctuation': /[{}[\]);,]/g,
'number': /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee][+-]?\d+)?)\b/,
'punctuation': /[{}[\]);,]/,
'operator': /:/g,
'boolean': /\b(true|false)\b/gi,
'null': /\bnull\b/gi
'boolean': /\b(?:true|false)\b/i,
'null': /\bnull\b/i
};

Prism.languages.jsonp = Prism.languages.json;
2 changes: 1 addition & 1 deletion components/prism-json.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8fc1b03

Please sign in to comment.