From bac19b8e0e820ef748439891f6bbd46aabb4fcf7 Mon Sep 17 00:00:00 2001 From: Teddy Date: Tue, 13 Aug 2013 14:34:15 +0800 Subject: in-place arithmetic opt & fix gc bug in `eval` --- gc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gc.cpp') diff --git a/gc.cpp b/gc.cpp index 4b6eaca..54248c3 100644 --- a/gc.cpp +++ b/gc.cpp @@ -48,13 +48,13 @@ void GarbageCollector::force() { } // fetch the pending pointers in the list // clear the list pending_list = NULL; */ - fprintf(stderr, "%ld\n", mapping.size()); for (EvalObj2Int::iterator it = mapping.begin(); it != mapping.end(); it++) if (it->second == 0) *r++ = it->first; collecting = true; #ifdef GC_INFO + fprintf(stderr, "%ld\n", mapping.size()); size_t cnt = 0; #endif #ifdef GC_DEBUG @@ -91,9 +91,10 @@ void GarbageCollector::force() { #endif #ifdef GC_DEBUG - for (EvalObj2Int::iterator it = mapping.begin(); +/* for (EvalObj2Int::iterator it = mapping.begin(); it != mapping.end(); it++) fprintf(stderr, "%llx => %s\n", (ull)it->first, it->first->ext_repr().c_str()); + */ #endif collecting = false; } @@ -107,7 +108,7 @@ EvalObj *GarbageCollector::attach(EvalObj *ptr) { fprintf(stderr, "GC: 0x%llx attached. count = %lu \"%s\"\n", (ull)ptr, mapping[ptr], ptr->ext_repr().c_str()); #endif - if (mapping.size() > GC_QUEUE_SIZE >> 1) + if (mapping.size() > GC_QUEUE_SIZE >> 2) force(); return ptr; // passing through } -- cgit v1.2.3