Forum Discussion
EnTerr
11 years agoRoku Guru
"Komag" wrote:
EDIT - This will work to check that it's either a String or a roString?
Yes. It will work with all* string types in B/S.
But would calling the function lose some of the snappiness? I mean if this is done many times per second, wouldn't it be faster to keep it direct, just use `getInterface(val, "ifString") <> invalid`? I have a LOT of functions, and I'm beginning to wonder if the game has to do a big search through all the functions to find the one with the right name and whether that takes time, sort of like looking up a key/value pair in an AA with . operator.
No on "big search". Tiny penalty for calling a global function (`function myFun() ...`) or local function (`localVar = function()... end function: ...: localVar(..)`). No runtime lookup by name is needed, it was done during compilation.
The convenience of having a type-check function greatly outweighs the small slowdown - easy to read, you can change implementation, less risk of typos (like proper capitalization, har-har). To put it in perspective, even as a function call `isString(id)`, it is still faster than `LCase(Type(id)) = "string" Or UCase(Type(id)) = "ROSTRING"` . BUt are TheEndless and RokuJoel - two BrS-experienced developers - losing sleep over that check code speed? No - and neither should you.
(*) all 6 of them, let me flourish some arcane knowledge here