mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2025-04-14 21:33:01 +00:00
replaced a needless linear walk through the shader text uberbuffer with a lookup
This commit is contained in:
parent
26f2f7966c
commit
9b350a7d0c
1 changed files with 6 additions and 26 deletions
|
@ -2048,42 +2048,22 @@ static shader_t* FinishShader()
|
|||
///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// scans the combined text of ALL shader files for the given shader name
|
||||
// searches the combined text of ALL shader files for the given shader name
|
||||
// return the body of the shader if found, else NULL
|
||||
|
||||
static const char* FindShaderInShaderText( const char* shadername )
|
||||
{
|
||||
const char* p;
|
||||
const char* token;
|
||||
|
||||
int hash = Q_FileHash(shadername, MAX_SHADERTEXT_HASH);
|
||||
const int hash = Q_FileHash( shadername, MAX_SHADERTEXT_HASH );
|
||||
|
||||
// since the hash table always contains all loaded shaders
|
||||
// there's no need to actually scan through s_shaderText itself
|
||||
for (int i = 0; shaderTextHashTable[hash][i]; i++) {
|
||||
p = shaderTextHashTable[hash][i];
|
||||
token = COM_ParseExt(&p, qtrue);
|
||||
if ( !Q_stricmp( token, shadername ) ) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
if (!s_shaderText)
|
||||
return NULL;
|
||||
p = s_shaderText;
|
||||
|
||||
// look for label
|
||||
while ( 1 ) {
|
||||
token = COM_ParseExt( &p, qtrue );
|
||||
if ( token[0] == 0 ) {
|
||||
break;
|
||||
}
|
||||
const char* p = shaderTextHashTable[hash][i];
|
||||
const char* const token = COM_ParseExt( &p, qtrue );
|
||||
|
||||
if ( !Q_stricmp( token, shadername ) ) {
|
||||
return p;
|
||||
}
|
||||
else {
|
||||
// skip the definition
|
||||
SkipBracedSection( &p );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in a new issue