Skip to content

Commit 6d26c9c

Browse files
committed
Fix blocking due to very slow regex execution in "parseFunction"
1 parent 960ebd0 commit 6d26c9c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const parseSubroutine = (line: TextLine) => {
7474
return _parse(line, MethodType.Subroutine);
7575
};
7676
export const _parse = (line: TextLine, type: MethodType) => {
77-
const functionRegEx = /([a-zA-Z]+(\([\w.=]+\))*)*\s*\bfunction\b\s*([a-zA-Z_][a-z0-9_]*)\s*\((\s*[a-z_][a-z0-9_,\s]*)*\s*(\)|\&)\s*(result\([a-z_][\w]*(\)|\&))*/i;
77+
const functionRegEx = /(?<=([a-zA-Z]+(\([\w.=]+\))*)*)\s*\bfunction\b\s*([a-zA-Z_][a-z0-9_]*)\s*\((\s*[a-z_][a-z0-9_,\s]*)*\s*(?:\)|\&)\s*(result\([a-z_][\w]*(?:\)|\&))*/i;
7878
const subroutineRegEx = /^\s*(?!\bend\b)\w*\s*\bsubroutine\b\s*([a-z][a-z0-9_]*)\s*(?:\((\s*[a-z][a-z0-9_,\s]*)*\s*(\)|\&))*/i;
7979
const regEx =
8080
type === MethodType.Subroutine ? subroutineRegEx : functionRegEx;

0 commit comments

Comments
 (0)