Commit 7c6b5218 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Dict change: scan manually instead of conservatively

parent c30e503e
# Test the speed of using strings as dictionary keys.
# We internally optimize many things to not use dictionaries,
# but there are some times that we can't.
def f():
d = {'a':1}
for i in xrange(3000000):
d['a']
d['a']
d['a']
d['a']
d['a']
d['a']
d['a']
d['a']
d['a']
d['a']
f()
......@@ -689,14 +689,10 @@ void BoxedDict::gcHandler(GCVisitor* v, Box* b) {
BoxedDict* d = (BoxedDict*)b;
// This feels like a cludge, but we need to find anything that
// the unordered_map might have allocated.
// Another way to handle this would be to rt_alloc the unordered_map
// as well, though that incurs extra memory dereferences which would
// be nice to avoid.
void** start = (void**)&d->d;
void** end = start + (sizeof(d->d) / 8);
v->visitPotentialRange(start, end);
for (auto p : d->d) {
v->visit(p.first);
v->visit(p.second);
}
}
void BoxedDictIterator::gcHandler(GCVisitor* v, Box* b) {
......
......@@ -661,7 +661,7 @@ struct PyLt {
class BoxedDict : public Box {
public:
typedef std::unordered_map<Box*, Box*, PyHasher, PyEq, StlCompatAllocator<std::pair<Box*, Box*>>> DictMap;
typedef std::unordered_map<Box*, Box*, PyHasher, PyEq> DictMap;
DictMap d;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment