HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Faster or slower than gamecache?

02-20-2007, 01:17 PM#1
RaveEye
Hey wc3. I created this little system to save and load an integer. It works like the gamecache where you save it under a name. Does anyone know if this is faster or slower than gamecache?

Thanks

Collapse JASS:
function SaveInteger takes string folder, string file, integer id returns nothing    
    set udg_folder[udg_counter] = folder+"~"+file+"~"+I2S(id)
    set udg_counter = udg_counter + 1
endfunction

function LoadInteger takes string folder, string file returns integer
local integer a = StringLength(folder)
local integer b = StringLength(file)
local integer z = 0
local integer loopx = 1
local integer loopy = udg_counter
loop
    exitwhen loopx > loopy
    if (folder+"~"+file+"~"==SubString(udg_folder[loopx],0,a+b+2)) then
        set z = S2I(SubString(udg_folder[loopx],a+b+2,StringLength(udg_folder[loopx])))  
    endif
    set loopx = loopx + 1
endloop
return z
endfunction


Collapse JASS:
call SaveInteger("abc","a",100)
set someinteger = LoadInteger("abc","a")
02-20-2007, 01:26 PM#2
Vexorian
It is much slower, leaks strings. and is limited to 8192 values.
02-20-2007, 01:29 PM#3
shadow1500
Gamecache is really not that slow like everyone make it to be. It is not used because of string leaks and bugs in gamecache allocation (profile issues), other than that, it is decent and a lot of stuff can be done with it.
Your code will be slower (a lot slower, and even slower as more and more data are added). I benchmarked gamecache natives, they are equivalent to a few function calls, and your code has a lot more.
02-20-2007, 01:32 PM#4
RaveEye
Ok thanks! Then I go back to use gamecache ..
Yes I know there is a maximum at 8192, but in my map I shouldnt use so many.