============ idProgram::GetType Returns a preexisting complex type that matches the parm, or allocates a new one and copies it out. ============ */
| 1158 | ============ |
| 1159 | */ |
| 1160 | idTypeDef *idProgram::GetType( idTypeDef &type, bool allocate ) { |
| 1161 | int i; |
| 1162 | |
| 1163 | //FIXME: linear search == slow |
| 1164 | for( i = types.Num() - 1; i >= 0; i-- ) { |
| 1165 | if ( types[ i ]->MatchesType( type ) && !strcmp( types[ i ]->Name(), type.Name() ) ) { |
| 1166 | return types[ i ]; |
| 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | if ( !allocate ) { |
| 1171 | return NULL; |
| 1172 | } |
| 1173 | |
| 1174 | // allocate a new one |
| 1175 | return AllocType( type ); |
| 1176 | } |
| 1177 | |
| 1178 | /* |
| 1179 | ============ |
no test coverage detected