engine/source/scriptlib/ScriptVariant.c
// find an existing constant before copy
find an existing constant before copy
find an existing constant before copy
void ScriptVariant_ParseStringConstant(ScriptVariant *var, CHAR *str)
{
    int i;
    for(i = 0; i < strcache_size; i++)
    {
        if (strcache[i].ref && strcmp(str, strcache[i].str) == 0)
        {
            var->strVal = i;
            strcache[i].ref++;
            var->vt = VT_STR;
            return;
        }
    }
    ScriptVariant_ChangeType(var, VT_STR);
    var->strVal = StrCache_CreateNewFrom(str);
}
void ScriptVariant_ParseStringConstant ( ScriptVariant * var , CHAR * str ) { int i ; for ( i = 0 ; i < strcache_size ; i ++ ) { if ( strcache [ i ] . ref && strcmp ( str , strcache [ i ] . str ) == 0 ) { var -> strVal = i ; strcache [ i ] . ref ++ ; var -> vt = VT_STR ; return ; } } ScriptVariant_ChangeType ( var , VT_STR ) ; var -> strVal = StrCache_CreateNewFrom ( str ) ; }
find an existing constant before copy
find an existing constant before copy
//assert(index<strcache_size); //assert(size>0);