lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [02/17] git commit: refs/heads/cfish-string-prep1 - Eliminate SStr_Assign_Str in boot.c
Date Fri, 13 Sep 2013 18:31:34 GMT
Eliminate SStr_Assign_Str in boot.c


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

Branch: refs/heads/cfish-string-prep1
Commit: 54ffcca520654d2f53d4bfef0f9d10efaed69193
Parents: 051e87b
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sat Sep 7 20:33:03 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Mon Sep 9 20:17:51 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/src/CFCPerl.c            | 27 ++++++------------------
 clownfish/runtime/core/Clownfish/VTable.c   |  6 ++++--
 clownfish/runtime/core/Clownfish/VTable.cfh |  3 ++-
 3 files changed, 13 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/54ffcca5/clownfish/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerl.c b/clownfish/compiler/src/CFCPerl.c
index 698d71a..2c873f5 100644
--- a/clownfish/compiler/src/CFCPerl.c
+++ b/clownfish/compiler/src/CFCPerl.c
@@ -208,7 +208,6 @@ S_write_boot_c(CFCPerl *self) {
     char *bootstrap_code  = CFCUtil_strdup("");
     char *alias_adds      = CFCUtil_strdup("");
     char *isa_pushes      = CFCUtil_strdup("");
-    int   has_aliases     = 0;
 
     for (size_t i = 0; parcels[i]; ++i) {
         if (!CFCParcel_included(parcels[i])) {
@@ -237,28 +236,16 @@ S_write_boot_c(CFCPerl *self) {
             const char **aliases
                 = CFCPerlClass_get_class_aliases(class_binding);
             for (size_t j = 0; aliases[j] != NULL; j++) {
-                if (!has_aliases) {
-                    // There's at least one alias, so include the buffer.
-                    alias_adds
-                        = CFCUtil_cat(alias_adds,
-                                      "    cfish_StackString *alias "
-                                      "= CFISH_SStr_WRAP_STR(\"\", 0);\n",
-                                      NULL);
-                    has_aliases = 1;
-                }
-
                 const char *alias = aliases[j];
                 size_t alias_len  = strlen(alias);
                 const char pattern[] =
-                    "%s"
-                    "    CFISH_SStr_Assign_Str(alias, \"%s\", %u);\n"
-                    "    cfish_VTable_add_alias_to_registry(%s,\n"
-                    "        (cfish_String*)alias);\n";
-                char *new_alias_adds
-                    = CFCUtil_sprintf(pattern, alias_adds, alias,
-                                      (unsigned)alias_len, vtable_var);
-                FREEMEM(alias_adds);
-                alias_adds = new_alias_adds;
+                    "    cfish_VTable_add_alias_to_registry("
+                    "%s, \"%s\", %u);\n";
+                char *alias_add
+                    = CFCUtil_sprintf(pattern, vtable_var, alias,
+                                      (unsigned)alias_len);
+                alias_adds = CFCUtil_cat(alias_adds, alias_add, NULL);
+                FREEMEM(alias_add);
             }
 
             char *metadata_code

http://git-wip-us.apache.org/repos/asf/lucy/blob/54ffcca5/clownfish/runtime/core/Clownfish/VTable.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/VTable.c b/clownfish/runtime/core/Clownfish/VTable.c
index 92ee50a..67ec977 100644
--- a/clownfish/runtime/core/Clownfish/VTable.c
+++ b/clownfish/runtime/core/Clownfish/VTable.c
@@ -362,15 +362,17 @@ VTable_add_to_registry(VTable *vtable) {
 }
 
 bool
-VTable_add_alias_to_registry(VTable *vtable, String *alias) {
+VTable_add_alias_to_registry(VTable *vtable, const char *alias_ptr,
+                             size_t alias_len) {
     if (VTable_registry == NULL) {
         VTable_init_registry();
     }
+    StackString *alias = SSTR_WRAP_STR(alias_ptr, alias_len);
     if (LFReg_Fetch(VTable_registry, (Obj*)alias)) {
         return false;
     }
     else {
-        String *klass = Str_Clone(alias);
+        String *klass = SStr_Clone(alias);
         bool retval
             = LFReg_Register(VTable_registry, (Obj*)klass, (Obj*)vtable);
         DECREF(klass);

http://git-wip-us.apache.org/repos/asf/lucy/blob/54ffcca5/clownfish/runtime/core/Clownfish/VTable.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/VTable.cfh b/clownfish/runtime/core/Clownfish/VTable.cfh
index 12bbef9..11d1669 100644
--- a/clownfish/runtime/core/Clownfish/VTable.cfh
+++ b/clownfish/runtime/core/Clownfish/VTable.cfh
@@ -61,7 +61,8 @@ class Clownfish::VTable inherits Clownfish::Obj {
     add_to_registry(VTable *vtable);
 
     inert bool
-    add_alias_to_registry(VTable *vtable, String *alias);
+    add_alias_to_registry(VTable *vtable, const char *alias_ptr,
+                          size_t alias_len);
 
     /** Initialize the registry.
      */


Mime
View raw message