Skip to content

Commit

Permalink
Go: 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 e66d21b commit 88caabb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions components/prism-go.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Prism.languages.go = Prism.languages.extend('clike', {
'keyword': /\b(break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
'builtin': /\b(bool|byte|complex(64|128)|error|float(32|64)|rune|string|u?int(8|16|32|64|)|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(ln)?|real|recover)\b/,
'boolean': /\b(_|iota|nil|true|false)\b/,
'keyword': /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
'builtin': /\b(?:bool|byte|complex(?:64|128)|error|float(?:32|64)|rune|string|u?int(?:8|16|32|64)?|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(?:ln)?|real|recover)\b/,
'boolean': /\b(?:_|iota|nil|true|false)\b/,
'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
'number': /\b(-?(0x[a-f\d]+|(\d+\.?\d*|\.\d+)(e[-+]?\d+)?)i?)\b/i,
'string': {
pattern: /("|'|`)(\\?.|\r|\n)*?\1/,
pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,
greedy: true
}
});
Expand Down
2 changes: 1 addition & 1 deletion components/prism-go.min.js

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

0 comments on commit 88caabb

Please sign in to comment.