You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2014/06/18 03:06:32 UTC

[lucy-commits] [10/16] git commit: refs/heads/master - Handle refcounting when clearing SortEx buffer.

Handle refcounting when clearing SortEx buffer.

Now that SortExternal only handles objects rather than addresses, it
makes sense to decref objects when emptying out the buffer.

This change is safe for all subclasses and incurs no performance penalty
under normal conditions -- unless something goes wrong all buffered
items will have already been consumed by the time the buffer-clearing
operation is invoked.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/88271ce1
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/88271ce1
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/88271ce1

Branch: refs/heads/master
Commit: 88271ce1059c6191bc6b946deb51c1aba48ca474
Parents: c09c1dc
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Tue Jan 8 17:22:23 2013 -0800
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Sat Apr 26 14:10:55 2014 -0700

----------------------------------------------------------------------
 core/Lucy/Util/BBSortEx.c     | 4 ----
 core/Lucy/Util/SortExternal.c | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/88271ce1/core/Lucy/Util/BBSortEx.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/BBSortEx.c b/core/Lucy/Util/BBSortEx.c
index 40238cf..c5c4c13 100644
--- a/core/Lucy/Util/BBSortEx.c
+++ b/core/Lucy/Util/BBSortEx.c
@@ -52,10 +52,6 @@ BBSortEx_Destroy_IMP(BBSortEx *self) {
 void
 BBSortEx_Clear_Cache_IMP(BBSortEx *self) {
     BBSortExIVARS *const ivars = BBSortEx_IVARS(self);
-    Obj **const cache = ivars->cache;
-    for (uint32_t i = ivars->cache_tick, max = ivars->cache_max; i < max; i++) {
-        DECREF(cache[i]);
-    }
     ivars->mem_consumed = 0;
     BBSortEx_Clear_Cache_t super_clear_cache
         = SUPER_METHOD_PTR(BBSORTEX, LUCY_BBSortEx_Clear_Cache);

http://git-wip-us.apache.org/repos/asf/lucy/blob/88271ce1/core/Lucy/Util/SortExternal.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/SortExternal.c b/core/Lucy/Util/SortExternal.c
index 434c34d..c4d936e 100644
--- a/core/Lucy/Util/SortExternal.c
+++ b/core/Lucy/Util/SortExternal.c
@@ -78,6 +78,11 @@ SortEx_Destroy_IMP(SortExternal *self) {
 void
 SortEx_Clear_Cache_IMP(SortExternal *self) {
     SortExternalIVARS *const ivars = SortEx_IVARS(self);
+    Obj **const cache = ivars->cache;
+    const uint32_t max = ivars->cache_max;
+    for (uint32_t i = ivars->cache_tick; i < max; i++) {
+        DECREF(cache[i]);
+    }
     ivars->cache_max    = 0;
     ivars->cache_tick   = 0;
 }