You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2014/07/26 15:36:12 UTC

[2/3] git commit: Generalize object struct optimization

Generalize object struct optimization

Populate object struct for objects if all ancestors are in the same
parcel. No more special casing of the cfish parcel.


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

Branch: refs/heads/ivars_fixes
Commit: 6e1e407e8216c8096de168da01e983d921026e27
Parents: 74cd3e0
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Jul 25 18:25:29 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Jul 26 15:34:30 2014 +0200

----------------------------------------------------------------------
 compiler/src/CFCBindClass.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/6e1e407e/compiler/src/CFCBindClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindClass.c b/compiler/src/CFCBindClass.c
index 3714d28..b767f19 100644
--- a/compiler/src/CFCBindClass.c
+++ b/compiler/src/CFCBindClass.c
@@ -422,25 +422,26 @@ CFCBindClass_to_c_data(CFCBindClass *self) {
 // Create the definition for the instantiable object struct.
 static char*
 S_struct_definition(CFCBindClass *self) {
-    CFCClass *const client = self->client;
-    const char *struct_sym;
-    const char *prefix = CFCClass_get_prefix(client);
-    if (strcmp(prefix, "cfish_") == 0) {
-        struct_sym = CFCClass_full_struct_sym(client);
-    }
-    else {
-        struct_sym = CFCClass_full_ivars_struct(client);
-    }
+    CFCClass   *const client = self->client;
+    const char *struct_sym   = NULL;
 
-    // Count the number of member variables declared in ancestor classes
-    // outside this package so that we can skip over them.
-    int num_non_package_members = 0;
+    // Try to find first ancestor from a different parcel.
     CFCParcel *parcel = CFCClass_get_parcel(client);
     CFCClass *ancestor = CFCClass_get_parent(client);
     while (ancestor && CFCClass_get_parcel(ancestor) == parcel) {
         ancestor = CFCClass_get_parent(ancestor);
     }
-    if (ancestor) {
+
+    int num_non_package_members = 0;
+    if (!ancestor) {
+        // All ancestors are in the same parcel. Populate full struct sym.
+        struct_sym = CFCClass_full_struct_sym(client);
+    }
+    else {
+        // There's an ancestor from a different parcel. Populate ivars struct.
+        struct_sym = CFCClass_full_ivars_struct(client);
+        // Count the number of member variables declared in ancestor classes
+        // outside this package so that we can skip over them.
         num_non_package_members = CFCClass_num_member_vars(ancestor);
     }