lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [1/4] git commit: refs/heads/cfish-string-prep1 - Eliminate mutable String in Util::Freezer
Date Thu, 05 Sep 2013 22:11:20 GMT
Updated Branches:
  refs/heads/cfish-string-prep1 56fb0e1dd -> 1f51cae0f


Eliminate mutable String in Util::Freezer


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

Branch: refs/heads/cfish-string-prep1
Commit: cfea9e6105e2ba7acac049ef27296358360dcb90
Parents: 56fb0e1
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Mon Sep 2 21:27:23 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Mon Sep 2 21:27:23 2013 +0200

----------------------------------------------------------------------
 core/Lucy/Util/Freezer.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/cfea9e61/core/Lucy/Util/Freezer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Freezer.c b/core/Lucy/Util/Freezer.c
index af425e5..cdaeffc 100644
--- a/core/Lucy/Util/Freezer.c
+++ b/core/Lucy/Util/Freezer.c
@@ -330,20 +330,19 @@ Freezer_deserialize_hash(Hash *hash, InStream *instream) {
     uint32_t size        = InStream_Read_C32(instream);
     uint32_t num_strings = InStream_Read_C32(instream);
     uint32_t num_other   = size - num_strings;
-    String *key          = num_strings ? Str_new(0) : NULL;
 
     Hash_init(hash, size);
 
     // Read key-value pairs with String keys.
     while (num_strings--) {
         uint32_t len = InStream_Read_C32(instream);
-        char *key_buf = Str_Grow(key, len);
+        char *key_buf = (char*)MALLOCATE(len + 1);
         InStream_Read_Bytes(instream, key_buf, len);
         key_buf[len] = '\0';
-        Str_Set_Size(key, len);
+        String *key = Str_new_steal_from_trusted_str(key_buf, len, len + 1);
         Hash_Store(hash, (Obj*)key, THAW(instream));
+        DECREF(key);
     }
-    DECREF(key);
 
     // Read remaining key/value pairs.
     while (num_other--) {


Mime
View raw message