speed up regex for block comments
This commit is contained in:
parent
484ff24950
commit
00b732177f
|
@ -622,7 +622,7 @@ function SectionsEditor() {
|
||||||
const text = event.clipboardData.getData('text') || '';
|
const text = event.clipboardData.getData('text') || '';
|
||||||
if (/@-moz-document/i.test(text) &&
|
if (/@-moz-document/i.test(text) &&
|
||||||
/@-moz-document\s+(url|url-prefix|domain|regexp)\(/i
|
/@-moz-document\s+(url|url-prefix|domain|regexp)\(/i
|
||||||
.test(text.replace(/\/\*([^*]|\*(?!\/))*(\*\/|$)/g, ''))
|
.test(text.replace(/\/\*([^*]+|\*(?!\/))*(\*\/|$)/g, ''))
|
||||||
) {
|
) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
showMozillaFormatImport(text);
|
showMozillaFormatImport(text);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
'(?=[\\s;(){}[\\]/"!]|$)' +
|
'(?=[\\s;(){}[\\]/"!]|$)' +
|
||||||
')', 'gi');
|
')', 'gi');
|
||||||
const RX_DETECT_FUNC = /((rgb|hsl)a?|hwb)\(/iy;
|
const RX_DETECT_FUNC = /((rgb|hsl)a?|hwb)\(/iy;
|
||||||
const RX_COMMENT = /\/\*([^*]|\*(?!\/))*(\*\/|$)/g;
|
const RX_COMMENT = /\/\*([^*]+|\*(?!\/))*(\*\/|$)/g;
|
||||||
const SPACE1K = ' '.repeat(1000);
|
const SPACE1K = ' '.repeat(1000);
|
||||||
|
|
||||||
// milliseconds to work on invisible colors per one run
|
// milliseconds to work on invisible colors per one run
|
||||||
|
|
|
@ -112,7 +112,7 @@ class Reporter {
|
||||||
//eslint-disable-next-line no-var
|
//eslint-disable-next-line no-var
|
||||||
var CSSLint = (() => {
|
var CSSLint = (() => {
|
||||||
|
|
||||||
const RX_EMBEDDED = /\/\*\s*csslint\s+((?:[^*]|\*(?!\/))+?)\*\//ig;
|
const RX_EMBEDDED = /\/\*\s*csslint\s+((?:[^*]+|\*(?!\/))+?)\*\//ig;
|
||||||
const EBMEDDED_RULE_VALUE_MAP = {
|
const EBMEDDED_RULE_VALUE_MAP = {
|
||||||
// error
|
// error
|
||||||
'true': 2,
|
'true': 2,
|
||||||
|
|
|
@ -3104,7 +3104,7 @@ self.parserlib = (() => {
|
||||||
readComment(first) {
|
readComment(first) {
|
||||||
return first +
|
return first +
|
||||||
this._reader.readCount(2 - first.length) +
|
this._reader.readCount(2 - first.length) +
|
||||||
this._reader.readMatch(/([^*]|\*(?!\/))*(\*\/|$)/y);
|
this._reader.readMatch(/([^*]+|\*(?!\/))*(\*\/|$)/y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -72,7 +72,7 @@ function styleCodeEmpty(code) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let lastIndex = 0;
|
let lastIndex = 0;
|
||||||
const rx = /\s+|\/\*([^*]|\*(?!\/))*(\*\/|$)|@namespace[^;]+;|@charset[^;]+;/giyu;
|
const rx = /\s+|\/\*([^*]+|\*(?!\/))*(\*\/|$)|@namespace[^;]+;|@charset[^;]+;/giyu;
|
||||||
while (rx.exec(code)) {
|
while (rx.exec(code)) {
|
||||||
lastIndex = rx.lastIndex;
|
lastIndex = rx.lastIndex;
|
||||||
if (lastIndex === code.length) {
|
if (lastIndex === code.length) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ function testGlobalCss() {
|
||||||
const css = fs.readFileSync('global.css', {encoding: 'utf8'});
|
const css = fs.readFileSync('global.css', {encoding: 'utf8'});
|
||||||
const ERR = 'global.css: missing the transition suppressor rule';
|
const ERR = 'global.css: missing the transition suppressor rule';
|
||||||
const RX_SUPPRESSOR = /[^{}]+#\\1\s?transition-suppressor[^{}]+{\s*transition:\s*none\s*!\s*important/i;
|
const RX_SUPPRESSOR = /[^{}]+#\\1\s?transition-suppressor[^{}]+{\s*transition:\s*none\s*!\s*important/i;
|
||||||
const RX_COMMENT = /\/\*([^*]|\*(?!\/))*(\*\/|$)/g;
|
const RX_COMMENT = /\/\*([^*]+|\*(?!\/))*(\*\/|$)/g;
|
||||||
if (!RX_SUPPRESSOR.test(css.replace(RX_COMMENT, ''))) {
|
if (!RX_SUPPRESSOR.test(css.replace(RX_COMMENT, ''))) {
|
||||||
console.error(ERR);
|
console.error(ERR);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user