Repository: lucy-clownfish
Updated Branches:
refs/heads/master 357c592be -> aab014633
Remove VA_Shift
This is a rarely used and unefficient opeeration. It can be replaced with:
Obj *elem = INCREF(VA_Fetch(array, 0)); // optional
VA_Excise(array, 0, 1);
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/5124e36c
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/5124e36c
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/5124e36c
Branch: refs/heads/master
Commit: 5124e36c0b42d73882ac16cb308d86cf5b2da39d
Parents: fa9b77b
Author: Nick Wellnhofer <[email protected]>
Authored: Sun Apr 26 12:04:58 2015 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Sun Apr 26 19:39:54 2015 +0200
----------------------------------------------------------------------
runtime/core/Clownfish/Test/TestVArray.c | 19 ++++++-------------
runtime/core/Clownfish/VArray.c | 16 ----------------
runtime/core/Clownfish/VArray.cfh | 5 -----
runtime/perl/buildlib/Clownfish/Build/Binding.pm | 8 --------
4 files changed, 6 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5124e36c/runtime/core/Clownfish/Test/TestVArray.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestVArray.c
b/runtime/core/Clownfish/Test/TestVArray.c
index b2a91f9..e6729dc 100644
--- a/runtime/core/Clownfish/Test/TestVArray.c
+++ b/runtime/core/Clownfish/Test/TestVArray.c
@@ -140,15 +140,13 @@ test_Store_Fetch(TestBatchRunner *runner) {
}
static void
-test_Push_Pop_Shift_Unshift(TestBatchRunner *runner) {
+test_Push_Pop_Unshift(TestBatchRunner *runner) {
VArray *array = VA_new(0);
String *elem;
TEST_INT_EQ(runner, VA_Get_Size(array), 0, "size starts at 0");
TEST_TRUE(runner, VA_Pop(array) == NULL,
"Pop from empty array returns NULL");
- TEST_TRUE(runner, VA_Shift(array) == NULL,
- "Shift from empty array returns NULL");
VA_Push(array, (Obj*)Str_newf("a"));
VA_Push(array, (Obj*)Str_newf("b"));
@@ -157,20 +155,15 @@ test_Push_Pop_Shift_Unshift(TestBatchRunner *runner) {
TEST_INT_EQ(runner, VA_Get_Size(array), 3, "size after Push");
TEST_TRUE(runner, NULL != CERTIFY(VA_Fetch(array, 2), STRING), "Push");
- elem = (String*)CERTIFY(VA_Shift(array), STRING);
- TEST_TRUE(runner, Str_Equals_Utf8(elem, "a", 1), "Shift");
- TEST_INT_EQ(runner, VA_Get_Size(array), 2, "size after Shift");
- DECREF(elem);
-
elem = (String*)CERTIFY(VA_Pop(array), STRING);
TEST_TRUE(runner, Str_Equals_Utf8(elem, "c", 1), "Pop");
- TEST_INT_EQ(runner, VA_Get_Size(array), 1, "size after Pop");
+ TEST_INT_EQ(runner, VA_Get_Size(array), 2, "size after Pop");
DECREF(elem);
VA_Unshift(array, (Obj*)Str_newf("foo"));
elem = (String*)CERTIFY(VA_Fetch(array, 0), STRING);
TEST_TRUE(runner, Str_Equals_Utf8(elem, "foo", 3), "Unshift");
- TEST_INT_EQ(runner, VA_Get_Size(array), 2, "size after Shift");
+ TEST_INT_EQ(runner, VA_Get_Size(array), 3, "size after Shift");
for (int i = 0; i < 256; ++i) {
VA_Push(array, (Obj*)Str_newf("flotsam"));
@@ -178,7 +171,7 @@ test_Push_Pop_Shift_Unshift(TestBatchRunner *runner) {
for (int i = 0; i < 512; ++i) {
VA_Unshift(array, (Obj*)Str_newf("jetsam"));
}
- TEST_INT_EQ(runner, VA_Get_Size(array), 2 + 256 + 512,
+ TEST_INT_EQ(runner, VA_Get_Size(array), 3 + 256 + 512,
"size after exercising Pop and Unshift");
DECREF(array);
@@ -551,10 +544,10 @@ test_Grow(TestBatchRunner *runner) {
void
TestVArray_Run_IMP(TestVArray *self, TestBatchRunner *runner) {
- TestBatchRunner_Plan(runner, (TestBatch*)self, 66);
+ TestBatchRunner_Plan(runner, (TestBatch*)self, 63);
test_Equals(runner);
test_Store_Fetch(runner);
- test_Push_Pop_Shift_Unshift(runner);
+ test_Push_Pop_Unshift(runner);
test_Delete(runner);
test_Resize(runner);
test_Excise(runner);
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5124e36c/runtime/core/Clownfish/VArray.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/VArray.c b/runtime/core/Clownfish/VArray.c
index 689032a..312811c 100644
--- a/runtime/core/Clownfish/VArray.c
+++ b/runtime/core/Clownfish/VArray.c
@@ -138,22 +138,6 @@ VA_Unshift_IMP(VArray *self, Obj *elem) {
}
Obj*
-VA_Shift_IMP(VArray *self) {
- if (!self->size) {
- return NULL;
- }
- else {
- Obj *const return_val = self->elems[0];
- self->size--;
- if (self->size > 0) {
- memmove(self->elems, self->elems + 1,
- self->size * sizeof(Obj*));
- }
- return return_val;
- }
-}
-
-Obj*
VA_Fetch_IMP(VArray *self, size_t num) {
if (num >= self->size) {
return NULL;
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5124e36c/runtime/core/Clownfish/VArray.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/VArray.cfh
b/runtime/core/Clownfish/VArray.cfh
index a502b12..8b8c991 100644
--- a/runtime/core/Clownfish/VArray.cfh
+++ b/runtime/core/Clownfish/VArray.cfh
@@ -65,11 +65,6 @@ class Clownfish::VArray nickname VA inherits Clownfish::Obj {
void
Unshift(VArray *self, decremented Obj *element = NULL);
- /** Shift an item off of the front of a VArray.
- */
- incremented nullable Obj*
- Shift(VArray *self);
-
/** Ensure that the VArray has room for at least `capacity`
* elements.
*/
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5124e36c/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 9b2325a..944c4d6 100644
--- a/runtime/perl/buildlib/Clownfish/Build/Binding.pm
+++ b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
@@ -487,7 +487,6 @@ END_XS_CODE
sub bind_varray {
my @hand_rolled = qw(
Shallow_Copy
- Shift
Pop
Delete
Store
@@ -512,13 +511,6 @@ CODE:
OUTPUT: RETVAL
SV*
-shift(self)
- cfish_VArray *self;
-CODE:
- RETVAL = CFISH_OBJ_TO_SV_NOINC(CFISH_VA_Shift(self));
-OUTPUT: RETVAL
-
-SV*
pop(self)
cfish_VArray *self;
CODE: