You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(database): eliminate repeated substring allocations in stripLeadingWhitespaceAndLineComments via micro-scanner #1515
In lib/core/database/sql_limit.dart (lines 24–40):
StringstripLeadingWhitespaceAndLineComments(String sql) {
var s = sql.trimLeft();
while (true) {
if (s.isEmpty) return s;
if (s.startsWith('--')) {
final nl = s.indexOf('\n');
if (nl ==-1) return'';
s = s.substring(nl +1).trimLeft(); // Full copy of the rest of the script!continue;
}
if (s.startsWith('/*')) {
s = s.substring(_blockCommentEnd(s, 0)).trimLeft(); // Another full copy!continue;
}
return s;
}
}
If a user executes a 10 MB SQL migration script or database dump that starts with 50 header comment lines (copyright, generator metadata, table comments), the while (true) loop copies the entire remaining 10 MB string on every single line, allocating up to 500 MB of heap memory ((N \cdot M)$ complexity) before running the query.
Activity
Merge pull request #1612 from QueryaHub/issue/1515-strip-leading-comm…
Merge pull request #1656 from QueryaHub/issue/1500-1515-1566-followups