mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-07 19:58:32 +09:00
[Perf] (ShaderTranspiler): memchr the mid-line #version scan and gate it on an accepted directive
This commit is contained in:
@@ -335,10 +335,15 @@ namespace {
|
||||
// #version splice the second into the tail of the first. Only an EXACT repeat of
|
||||
// the directive already accepted is recognized here; see
|
||||
// BlankRedundantVersionDirectives for why that one is tolerated and nothing else.
|
||||
for (SizeT scan = probe; scan < lineEnd; ++scan) {
|
||||
if (code[scan] != '#') continue;
|
||||
recordIfRedundant(scan, lineEnd);
|
||||
break;
|
||||
//
|
||||
// Gated on a directive having been accepted already, so an ordinary shader - which
|
||||
// has none of these - pays one memchr per line past its #version line and nothing
|
||||
// before it.
|
||||
if (info.hasValidVersionDirective) {
|
||||
const SizeT hashPos = code.find('#', probe);
|
||||
if (hashPos != MobileGL::String::npos && hashPos < lineEnd) {
|
||||
recordIfRedundant(hashPos, lineEnd);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const SizeT directiveStart = probe;
|
||||
|
||||
Reference in New Issue
Block a user