[Archipelago-submits] [188] trunk/oneliner: changed to memcpy instead of homemade stuff.

nobody at rubyforge.org nobody at rubyforge.org
Wed Jan 24 07:25:06 EST 2007


Revision: 188
Author:   zond
Date:     2007-01-24 07:25:06 -0500 (Wed, 24 Jan 2007)

Log Message:
-----------
changed to memcpy instead of homemade stuff. better benchmarking output

Modified Paths:
--------------
    trunk/oneliner/ext/superstring_ext.c
    trunk/oneliner/tests/superstring_benchmark.rb

Modified: trunk/oneliner/ext/superstring_ext.c
===================================================================
--- trunk/oneliner/ext/superstring_ext.c	2007-01-24 11:03:23 UTC (rev 187)
+++ trunk/oneliner/ext/superstring_ext.c	2007-01-24 12:25:06 UTC (rev 188)
@@ -16,7 +16,6 @@
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #include "ruby.h"
-#include <math.h>
 #include <limits.h>
 #include <openssl/aes.h>
 
@@ -213,12 +212,7 @@
   VALUE get_func = rb_intern("[]");
   VALUE this_block;
 
-  for (tmp = 0; tmp < RSTRING(block)->len / 4; tmp++) {
-    ( (int *) xor_sum )[tmp] = ( (int *) RSTRING(block)->ptr )[tmp];
-  }
-  for (tmp = 0; tmp < (RSTRING(block)->len % 4); tmp++) {
-    xor_sum[RSTRING(block)->len - tmp - 1] = RSTRING(block)->ptr[RSTRING(block)->len - tmp - 1];
-  }
+  memcpy(xor_sum, RSTRING(block)->ptr, RSTRING(block)->len);
 
   for (tmp = 0; tmp < NUM2INT(degree); tmp++) {
     rb_str_modify(context);

Modified: trunk/oneliner/tests/superstring_benchmark.rb
===================================================================
--- trunk/oneliner/tests/superstring_benchmark.rb	2007-01-24 11:03:23 UTC (rev 187)
+++ trunk/oneliner/tests/superstring_benchmark.rb	2007-01-24 12:25:06 UTC (rev 188)
@@ -20,7 +20,7 @@
 
   def decode(n)
     s2 = Oneliner::SuperString.new(" " * n)
-    bm("#{n} bytes mixed", :n => 10) do
+    bm("#{n} bytes mixed twice", :n => 10) do
       s = Oneliner::SuperString.new
       nil while s.decode!(s2.encode((n * 0.4).to_i + 8))
       s = Oneliner::SuperString.new




More information about the Archipelago-submits mailing list