Commit 850df400 authored by Marius Wachtler's avatar Marius Wachtler

TraceStack: when visiting a range preallocate the elements.

Improves performance of raytrace.py from about 10secs to 7secs.
parent 56242493
...@@ -55,6 +55,7 @@ void TraceStackGCVisitor::visit(void* p) { ...@@ -55,6 +55,7 @@ void TraceStackGCVisitor::visit(void* p) {
} }
void TraceStackGCVisitor::visitRange(void** start, void** end) { void TraceStackGCVisitor::visitRange(void** start, void** end) {
stack->reserve(end-start);
while (start < end) { while (start < end) {
_visit(*start); _visit(*start);
start++; start++;
......
...@@ -59,6 +59,10 @@ class TraceStack { ...@@ -59,6 +59,10 @@ class TraceStack {
return v.size(); return v.size();
} }
void reserve(int num) {
v.reserve(num + size());
}
void* pop() { void* pop() {
if (v.size()) { if (v.size()) {
void* r = v.back(); void* r = v.back();
......
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