PDA

View Full Version : [OGL] isIndexing



Lucidity
01-11-2016, 10:57 PM
Well, figured this looks nicer and is pretty neat.


function isIndexing(id: uInt32;option: string): boolean;
begin
if execRegExpr('^(m(odels)?)$',option) then
begin
if (ogl.getModels(id).indexes()) then exit(true);
end else if execRegExpr('^(t(extures)?)$',option) then
begin
if (ogl.getTextures(id).indexes()) then exit(true);
end;
end;

example usage: (123 is the model/texture ID depending on the string)
if isIndexing(123, 'm') then
if isIndexing(123, 'models') then
if isIndexing(123, 't') then
if isIndexing(123, 'textures') then

tls
01-12-2016, 12:34 AM
Regex is usually considered to be slow, so this should probably use a different method to check. I would honestly say it could and should use a constant.

Lucidity
01-12-2016, 01:39 AM
Regex is usually considered to be slow, so this should probably use a different method to check. I would honestly say it could and should use a constant.

Thanks for the advice

Justin
01-12-2016, 02:23 AM
Moved to correct section.

riwu
01-12-2016, 02:41 AM
Regex is usually considered to be slow, so this should probably use a different method to check. I would honestly say it could and should use a constant.
For simple short regex like that it should be negligible time though? (<1ms)
Though i agree should always use const/enum for these cases.