06.05.2016, 20:10
How can you optimize? Thank you.
MySQL R39-5 | pBlueG
MySQL R39-5 | pBlueG
Код:
stock LoadSpawns() { new time = GetTickCount(); new Cache:result = Db::query(connDb, "SELECT * FROM `"#__TableSpawns__"` ORDER BY `id` ASC"); new rows = cache_get_row_count(); if(rows) { for(new i; i < rows; i++) { new id; id = cache_get_row_int(i, 0); SpawnInfo[i][spInt] = cache_get_row_int(id, 1); SpawnInfo[i][spVirt] = cache_get_row_int(id, 2); SpawnInfo[i][spX] = cache_get_row_int(id, 3); SpawnInfo[i][spY] = cache_get_row_int(id, 4); SpawnInfo[i][spZ] = cache_get_row_int(id, 5); SpawnInfo[i][spA] = cache_get_row_int(id, 6); } debug("LoadSpawns() - Ok! Spawns: %i. Run time: %i (ms)", rows, GetTickCount()-time); } cache_delete(result); return 1; }
Код:
stock LoadFracInfo() { new time = GetTickCount(); format(query, sizeof query, "SELECT * FROM `"#__TableFracInfo__"` ORDER BY `fID` ASC"); new Cache:result = Db::query(connDb, query, true); new rows = cache_get_row_count(); if(rows) { strmid(FracInfo[0][fName], "Civilian", 0, strlen("Civilian"), 255); for(new i; i < rows; i++) { new fracid; fracid = cache_get_row_int(i, 0); FracInfo[fracid][fBank] = cache_get_row_int(i, 1); cache_get_str(i, 2, "p<,>a<i>[3]", FracInfo[fracid][fRConf]); cache_get_str(i, 3, "p<,>a<i>[2]", FracInfo[fracid][fBConf]); cache_get_row(i, 4, FracInfo[fracid][fName], connDb, 36); cache_get_row(i, 5, FracInfo[fracid][fTag], connDb, 16); cache_get_str(i, 6, "p<,>a<i>[2]a<f>[4]", FracInfo[fracid][fSpawn][fSpawnInt], FracInfo[fracid][fSpawn][fSpawnPos]); cache_get_str(i, 7, "h", FracInfo[fracid][fColor]); Iter::Add(Frac, fracid); } debug("LoadFracInfo() - Ok! Fracs: %i. Run time: %i (ms)", Iter::Count(Frac), GetTickCount()-time); } cache_delete(result); return 1; }