Merge pull request #15 from jcushman/patch-1

2x faster layout analysis: Use set instead of list for Plane's internal collection of objects.
pull/1/head
Yusuke Shinyama 2013-04-09 02:39:46 -07:00
commit 19e7d70ac1
1 changed files with 2 additions and 2 deletions

View File

@ -246,7 +246,7 @@ class ObjIdRange(object):
class Plane(object): class Plane(object):
def __init__(self, objs=None, gridsize=50): def __init__(self, objs=None, gridsize=50):
self._objs = [] self._objs = set()
self._grid = {} self._grid = {}
self.gridsize = gridsize self.gridsize = gridsize
if objs is not None: if objs is not None:
@ -281,7 +281,7 @@ class Plane(object):
else: else:
r = self._grid[k] r = self._grid[k]
r.append(obj) r.append(obj)
self._objs.append(obj) self._objs.add(obj)
return return
# remove(obj): displace an object. # remove(obj): displace an object.