Skip to content

Commit

Permalink
speed up slow regex
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Oct 16, 2020
1 parent 4c39123 commit 56deee5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/languages/mipsasm.js
Expand Up @@ -36,18 +36,18 @@ export default function(hljs) {
begin: '\\b('+ //mnemonics
// 32-bit integer instructions
'addi?u?|andi?|b(al)?|beql?|bgez(al)?l?|bgtzl?|blezl?|bltz(al)?l?|' +
'bnel?|cl[oz]|divu?|ext|ins|j(al)?|jalr(\.hb)?|jr(\.hb)?|lbu?|lhu?|' +
'bnel?|cl[oz]|divu?|ext|ins|j(al)?|jalr(\\.hb)?|jr(\\.hb)?|lbu?|lhu?|' +
'll|lui|lw[lr]?|maddu?|mfhi|mflo|movn|movz|move|msubu?|mthi|mtlo|mul|' +
'multu?|nop|nor|ori?|rotrv?|sb|sc|se[bh]|sh|sllv?|slti?u?|srav?|' +
'srlv?|subu?|sw[lr]?|xori?|wsbh|' +
// floating-point instructions
'abs\.[sd]|add\.[sd]|alnv.ps|bc1[ft]l?|' +
'c\.(s?f|un|u?eq|[ou]lt|[ou]le|ngle?|seq|l[et]|ng[et])\.[sd]|' +
'(ceil|floor|round|trunc)\.[lw]\.[sd]|cfc1|cvt\.d\.[lsw]|' +
'cvt\.l\.[dsw]|cvt\.ps\.s|cvt\.s\.[dlw]|cvt\.s\.p[lu]|cvt\.w\.[dls]|' +
'div\.[ds]|ldx?c1|luxc1|lwx?c1|madd\.[sd]|mfc1|mov[fntz]?\.[ds]|' +
'msub\.[sd]|mth?c1|mul\.[ds]|neg\.[ds]|nmadd\.[ds]|nmsub\.[ds]|' +
'p[lu][lu]\.ps|recip\.fmt|r?sqrt\.[ds]|sdx?c1|sub\.[ds]|suxc1|' +
'abs\\.[sd]|add\\.[sd]|alnv.ps|bc1[ft]l?|' +
'c\\.(s?f|un|u?eq|[ou]lt|[ou]le|ngle?|seq|l[et]|ng[et])\\.[sd]|' +
'(ceil|floor|round|trunc)\\.[lw]\\.[sd]|cfc1|cvt\\.d\\.[lsw]|' +
'cvt\\.l\\.[dsw]|cvt\\.ps\\.s|cvt\\.s\\.[dlw]|cvt\\.s\\.p[lu]|cvt\\.w\\.[dls]|' +
'div\\.[ds]|ldx?c1|luxc1|lwx?c1|madd\\.[sd]|mfc1|mov[fntz]?\\.[ds]|' +
'msub\\.[sd]|mth?c1|mul\\.[ds]|neg\\.[ds]|nmadd\\.[ds]|nmsub\\.[ds]|' +
'p[lu][lu]\\.ps|recip\\.fmt|r?sqrt\\.[ds]|sdx?c1|sub\\.[ds]|suxc1|' +
'swx?c1|' +
// system control instructions
'break|cache|d?eret|[de]i|ehb|mfc0|mtc0|pause|prefx?|rdhwr|' +
Expand All @@ -57,7 +57,7 @@ export default function(hljs) {
end: '\\s'
},
// lines ending with ; or # aren't really comments, probably auto-detect fail
hljs.COMMENT('[;#](?!\s*$)', '$'),
hljs.COMMENT('[;#](?!\\s*$)', '$'),
hljs.C_BLOCK_COMMENT_MODE,
hljs.QUOTE_STRING_MODE,
{
Expand Down Expand Up @@ -90,6 +90,6 @@ export default function(hljs) {
relevance: 0
}
],
illegal: '\/'
illegal: /\//
};
}
2 changes: 1 addition & 1 deletion src/languages/yaml.js
Expand Up @@ -102,7 +102,7 @@ export default function(hljs) {
// Indentation of subsequent lines must be the same to
// be considered part of the block
className: 'string',
begin: '[\\|>]([0-9]?[+-])?[ ]*\\n( *)[\\S ]+\\n(\\2[\\S ]+\\n?)*'
begin: '[\\|>]([0-9]?[+-])?[ ]*\\n( *)[^\\n]+\\n(\\2[^\\n]+\\n?)*'
},
{ // Ruby/Rails erb
begin: '<%[%=-]?',
Expand Down

0 comments on commit 56deee5

Please sign in to comment.