Fixed regex thanks @mloc. Using reg.test instead of string.match, mucho speed improvements

This commit is contained in:
Noah Santschi-Cooney 2018-05-14 21:05:42 +01:00
parent 188ad2a419
commit 2d37440ab2
No known key found for this signature in database
GPG key ID: 3B22282472C8AE48

View file

@ -91,7 +91,7 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
)
} else {
// Do we want this here? ¯\_(ツ)_/¯
vscode.window.showInformationMessage('[MC-GLSL] glslangValidator found!')
//vscode.window.showInformationMessage('[MC-GLSL] glslangValidator found!')
}
}
@ -108,10 +108,7 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
// This doesnt work yet >:( note: use .test instead of .match
private matchesFilters(s: string): boolean {
return filters.some((reg: RegExp, i: number, array: RegExp[]) => {
let m = s.match(reg)
console.log(s)
console.log(m)
return (m && m.length > 1)!
return reg.test(s)
})
}
@ -132,9 +129,9 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
let lines = res.split(/(?:\n)/g)
.filter((s: string) => { return s != '' })
.slice(1, -1)
//.filter((s: string) => { return !this.matchesFilters(s)} )
.filter((s: string) => { return this.matchesFilters(s)} )
if (lines.length < 1) {
if (lines.length < 1) {
// If there were no errors, we need to set the list empty so that the editor reflects that
this.diagnosticCollection.set(document.uri, [])
return
@ -143,7 +140,7 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
let diags: vscode.Diagnostic[] = []
lines.forEach((line: string) => {
let matches = line.match(/WARNING:|ERROR:\s\d+:(\d+): (\W.*)/)
let matches = line.match(/(?:WARNING:|ERROR:)\s\d+:(\d+): (\W.*)/)
if (!matches || (matches && matches.length < 3)) {
return
}