lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [08/22] lucy-clownfish git commit: Make VA_Shallow_Copy the default Clone operation
Date Wed, 29 Apr 2015 19:55:09 GMT
Make VA_Shallow_Copy the default Clone operation


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

Branch: refs/heads/master
Commit: 790694a8606e02372bad6cdcda82ad0d886083cf
Parents: 54c42e4
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sun Apr 26 14:11:39 2015 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sun Apr 26 19:40:21 2015 +0200

----------------------------------------------------------------------
 runtime/core/Clownfish/Test/TestVArray.c         | 16 +++++-----------
 runtime/core/Clownfish/VArray.c                  | 18 ------------------
 runtime/core/Clownfish/VArray.cfh                |  5 -----
 runtime/perl/buildlib/Clownfish/Build/Binding.pm |  8 --------
 4 files changed, 5 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/790694a8/runtime/core/Clownfish/Test/TestVArray.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestVArray.c b/runtime/core/Clownfish/Test/TestVArray.c
index 03aaf60..acda0d2 100644
--- a/runtime/core/Clownfish/Test/TestVArray.c
+++ b/runtime/core/Clownfish/Test/TestVArray.c
@@ -340,7 +340,7 @@ test_Slice(TestBatchRunner *runner) {
 }
 
 static void
-test_Clone_and_Shallow_Copy(TestBatchRunner *runner) {
+test_Clone(TestBatchRunner *runner) {
     VArray *array = VA_new(0);
     VArray *twin;
     uint32_t i;
@@ -349,16 +349,10 @@ test_Clone_and_Shallow_Copy(TestBatchRunner *runner) {
         VA_Push(array, (Obj*)Int32_new(i));
     }
     VA_Push(array, NULL);
-    twin = VA_Shallow_Copy(array);
-    TEST_TRUE(runner, VA_Equals(array, (Obj*)twin), "Shallow_Copy");
-    TEST_TRUE(runner, VA_Fetch(array, 1) == VA_Fetch(twin, 1),
-              "Shallow_Copy doesn't clone elements");
-    DECREF(twin);
-
     twin = VA_Clone(array);
     TEST_TRUE(runner, VA_Equals(array, (Obj*)twin), "Clone");
-    TEST_TRUE(runner, VA_Fetch(array, 1) != VA_Fetch(twin, 1),
-              "Clone performs deep clone");
+    TEST_TRUE(runner, VA_Fetch(array, 1) == VA_Fetch(twin, 1),
+              "Clone doesn't clone elements");
 
     DECREF(array);
     DECREF(twin);
@@ -517,7 +511,7 @@ test_Grow(TestBatchRunner *runner) {
 
 void
 TestVArray_Run_IMP(TestVArray *self, TestBatchRunner *runner) {
-    TestBatchRunner_Plan(runner, (TestBatch*)self, 62);
+    TestBatchRunner_Plan(runner, (TestBatch*)self, 60);
     test_Equals(runner);
     test_Store_Fetch(runner);
     test_Push_Pop_Insert(runner);
@@ -526,7 +520,7 @@ TestVArray_Run_IMP(TestVArray *self, TestBatchRunner *runner) {
     test_Excise(runner);
     test_Push_All(runner);
     test_Slice(runner);
-    test_Clone_and_Shallow_Copy(runner);
+    test_Clone(runner);
     test_exceptions(runner);
     test_Sort(runner);
     test_Gather(runner);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/790694a8/runtime/core/Clownfish/VArray.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/VArray.c b/runtime/core/Clownfish/VArray.c
index b5e9fc5..bcb367f 100644
--- a/runtime/core/Clownfish/VArray.c
+++ b/runtime/core/Clownfish/VArray.c
@@ -65,24 +65,6 @@ VA_Destroy_IMP(VArray *self) {
 
 VArray*
 VA_Clone_IMP(VArray *self) {
-    VArray *twin = VA_new(self->size);
-
-    // Clone each element.
-    for (size_t i = 0; i < self->size; i++) {
-        Obj *elem = self->elems[i];
-        if (elem) {
-            twin->elems[i] = Obj_Clone(elem);
-        }
-    }
-
-    // Ensure that size is the same if NULL elems at end.
-    twin->size = self->size;
-
-    return twin;
-}
-
-VArray*
-VA_Shallow_Copy_IMP(VArray *self) {
     // Dupe, then increment refcounts.
     VArray *twin = VA_new(self->size);
     Obj **elems = twin->elems;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/790694a8/runtime/core/Clownfish/VArray.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/VArray.cfh b/runtime/core/Clownfish/VArray.cfh
index 807067c..274f746 100644
--- a/runtime/core/Clownfish/VArray.cfh
+++ b/runtime/core/Clownfish/VArray.cfh
@@ -102,11 +102,6 @@ class Clownfish::VArray nickname VA inherits Clownfish::Obj {
     /** Clone the VArray but merely increment the refcounts of its elements
      * rather than clone them.
      */
-    incremented VArray*
-    Shallow_Copy(VArray *self);
-
-    /** Dupe the VArray, cloning each internal element.
-     */
     public incremented VArray*
     Clone(VArray *self);
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/790694a8/runtime/perl/buildlib/Clownfish/Build/Binding.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/buildlib/Clownfish/Build/Binding.pm b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
index 944c4d6..bbb7035 100644
--- a/runtime/perl/buildlib/Clownfish/Build/Binding.pm
+++ b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
@@ -486,7 +486,6 @@ END_XS_CODE
 
 sub bind_varray {
     my @hand_rolled = qw(
-        Shallow_Copy
         Pop
         Delete
         Store
@@ -497,13 +496,6 @@ sub bind_varray {
 MODULE = Clownfish   PACKAGE = Clownfish::VArray
 
 SV*
-shallow_copy(self)
-    cfish_VArray *self;
-CODE:
-    RETVAL = CFISH_OBJ_TO_SV_NOINC(CFISH_VA_Shallow_Copy(self));
-OUTPUT: RETVAL
-
-SV*
 _clone(self)
     cfish_VArray *self;
 CODE:


Mime
View raw message