[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-459-gef1b935

Mildred Ki'Lya silkensedai at online.fr
Tue Sep 1 01:01:08 UTC 2009


The following commit has been merged in the master branch:
commit ef1b935ca469d068a22f629019eba9af075962f8
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date:   Tue Sep 1 02:38:03 2009 +0200

    Optimize + and += operators on STRINGs.
    
    Those operators return a STRING_BUFFER that will just append to a STRING
    instead of creating a new STRING.

diff --git a/lib/string/abstract_string.li b/lib/string/abstract_string.li
index 38ae68d..d9bdc92 100644
--- a/lib/string/abstract_string.li
+++ b/lib/string/abstract_string.li
@@ -931,19 +931,21 @@ Section Public
   // Modification:
   //
   
-  - Self:SELF '+' other:ABSTRACT_STRING :STRING <-
+  - Self:SELF '+' other:ABSTRACT_STRING :STRING_BUFFER <-
   // Create a new STRING which is the concatenation of
   // `self' and `other'.
-  ( + result:STRING;
-    ? {other != NULL};
-    
-    result:=STRING.create (count + other.count);
+  [
+    -? {other != NULL};
+  ]
+  ( + result:STRING_BUFFER;
+    result:=STRING_BUFFER.create (count + other.count);
     result.append Self;
     result.append other;
-    
-    ? {result.count = count + other.count};
     result
-  );
+  )
+  [
+    +? {Result.count = count + other.count};
+  ];
     
   - as_lower:STRING <-
   // New object with all letters in lower case.
diff --git a/lib/string/string.li b/lib/string/string.li
index 39c3b9f..7917882 100644
--- a/lib/string/string.li
+++ b/lib/string/string.li
@@ -223,7 +223,7 @@ Section Public
     count := needed_capacity;
   );
   
-  - Self:SELF '+=' Left other:ABSTRACT_STRING :SELF <-
+  - Self:SELF '+=' Right other:ABSTRACT_STRING :STRING_BUFFER <-
   (
     append other;
     Self
diff --git a/lib/number/integer_8.li b/lib/string/string_buffer.li
similarity index 68%
copy from lib/number/integer_8.li
copy to lib/string/string_buffer.li
index fafaa16..206ab32 100644
--- a/lib/number/integer_8.li
+++ b/lib/string/string_buffer.li
@@ -19,53 +19,48 @@
 //                     http://isaacproject.u-strasbg.fr/                     //
 ///////////////////////////////////////////////////////////////////////////////
 Section Header
-  
-  + name    :=Expanded INTEGER_8;
 
-  - export  := INTEGER, INTEGER_64, INTEGER_32, INTEGER_16;
+  + name      := Expanded STRING_BUFFER;
 
-  - copyright   := 
-  "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag, 2007 Xavier Oswald";
+  - import    := STRING;
+  - export    := STRING;
 
-  - comment :="Signed 8 bits integer.";
+  - copyright := "2009 Mildred <http://ki.lya.online.fr>";
+
+  - comment   := "String buffer";
 
-  - type    := `signed char`;
-  - default := (`(0)`:INTEGER_8); //CONVERT[INTEGER,INTEGER_8].on 0); //0.to_raw_integer_8);
-  
 Section Insert
-  
-  - parent_signed_integer:SIGNED_INTEGER := SIGNED_INTEGER;
-  
-Section Public
 
-  - object_size:INTEGER := 1;
-  
-  //
-  // Range
-  //
-  
-  - maximum:UINTEGER_64 <- 127.to_raw_uinteger_64;
-  
-  - minimum:INTEGER_64  <- - 127.to_raw_integer_64;
-  
-  //
-  // Conversion.
-  //
-  
-  - to_integer_8:INTEGER_8 <- 
-  [ ]
-  (
-    Self
-  )
-  [ ];
+  + parent_string: STRING := STRING;
 
-  - to_character:CHARACTER <- `@Self`:CHARACTER; // `13`;
-  
+Section Private
 
+  - set_parent s:STRING <- (parent_string := s;);
 
+Section Public
 
-	
+  - clone :SELF <-
+  ( + result :SELF;
+    + str :STRING;
+    str := parent_string;
+    result.set_parent (str.create 0);
+    result
+  );
 
+  - create_from s:STRING :SELF <-
+  ( + result :SELF;
+    result.set_parent s;
+    result
+  );
 
+  - from_string s:STRING :SELF <- create_from s;
 
+  - to_string :STRING <- parent_string;
 
+  - Self:SELF '+' other:ABSTRACT_STRING :STRING_BUFFER <-
+  // Create a new STRING_BUFFER which is the concatenation of
+  // `self' and `other'.
+  (
+    append other;
+    Self
+  );

-- 
Lisaac compiler



More information about the Lisaac-commits mailing list