From 79d021279f75f2b1dbf48b7c11bcd57bf50e5173 Mon Sep 17 00:00:00 2001 From: Xon Date: Sat, 19 Mar 2011 13:59:40 +0800 Subject: [PATCH] Tweaked _get_chunks_in_range & related call tree. ~12% improvement by inlining self.world.get_region_path ina pure update scan. --- quadtree.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/quadtree.py b/quadtree.py index 692a9a5..fbee945 100644 --- a/quadtree.py +++ b/quadtree.py @@ -428,6 +428,9 @@ class QuadtreeGen(object): """Get chunks that are relevant to the tile rendering function that's rendering that range""" chunklist = [] + unconvert_coords = self.world.unconvert_coords + #get_region_path = self.world.get_region_path + get_region = self.world.regionfiles.get for row in xrange(rowstart-16, rowend+1): for col in xrange(colstart, colend+1): # due to how chunks are arranged, we can only allow @@ -437,8 +440,9 @@ class QuadtreeGen(object): continue # return (col, row, chunkx, chunky, regionpath) - chunkx, chunky = self.world.unconvert_coords(col, row) - c = self.world.get_region_path(chunkx, chunky) + chunkx, chunky = unconvert_coords(col, row) + #c = get_region_path(chunkx, chunky) + _, _, c = get_region((chunkx//32, chunky//32),(None,None,None)); if c is not None: chunklist.append((col, row, chunkx, chunky, c)) return chunklist