[svn:parrot] r35621 - branches/strings/pseudocode

[email protected]
Newsgroups perl.cvs.parrot
Message-ID <[email protected]>
Author: simon
Date: Fri Jan 16 03:42:02 2009
New Revision: 35621

Modified:
   branches/strings/pseudocode/Encodings.pm
   branches/strings/pseudocode/ParrotString.pm

Log:
Variable string encodings can have their own base class too.


Modified: branches/strings/pseudocode/Encodings.pm
==============================================================================
--- branches/strings/pseudocode/Encodings.pm	(original)
+++ branches/strings/pseudocode/Encodings.pm	Fri Jan 16 03:42:02 2009
@@ -32,7 +32,7 @@
     }
 }
 
-class ParrotEncoding::UTF8   {  
+class ParrotEncoding::UTF8 is ParrotEncoding::Base::Variable {  
     sub _skip($c) {
         if $c <= 191 { return 1 }
         if 191 < $c < 224 { return 2 }

Modified: branches/strings/pseudocode/ParrotString.pm
==============================================================================
--- branches/strings/pseudocode/ParrotString.pm	(original)
+++ branches/strings/pseudocode/ParrotString.pm	Fri Jan 16 03:42:02 2009
@@ -60,10 +60,7 @@
 }
 
 sub Parrot_string_length($str) {
-    # This code written funny to be a bit more C-like
-    my $data = 0; my $callback = sub ($char, $data is rw) { $data++ };
-    $str.encoding.string_char_iterate($str, $callback, $data);
-    return $data;
+    return $str.encoding.string_length($str); # Let fixies optimize themselves
 }
 
 sub Parrot_string_grapheme_length($str) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.