[前][次][番号順一覧][スレッド一覧]

ruby-changes:12809

From: nobu <ko1@a...>
Date: Fri, 14 Aug 2009 16:28:55 +0900 (JST)
Subject: [ruby-changes:12809] Ruby:r24537 (trunk): * ext/digest/lib/digest/hmac.rb (Digest::HMAC#initialize): faster

nobu	2009-08-14 16:28:26 +0900 (Fri, 14 Aug 2009)

  New Revision: 24537

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24537

  Log:
    * ext/digest/lib/digest/hmac.rb (Digest::HMAC#initialize): faster
      code.

  Modified files:
    trunk/ChangeLog
    trunk/ext/digest/lib/digest/hmac.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 24536)
+++ ChangeLog	(revision 24537)
@@ -1,3 +1,8 @@
+Fri Aug 14 16:28:19 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/digest/lib/digest/hmac.rb (Digest::HMAC#initialize): faster
+	  code.
+
 Fri Aug 14 14:31:33 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (rubyhdrdir): fixed typo.  [ruby-dev:39079]
Index: ext/digest/lib/digest/hmac.rb
===================================================================
--- ext/digest/lib/digest/hmac.rb	(revision 24536)
+++ ext/digest/lib/digest/hmac.rb	(revision 24537)
@@ -49,8 +49,8 @@
         key = @md.digest(key)
       end
 
-      ipad = Array.new(block_len).fill(0x36)
-      opad = Array.new(block_len).fill(0x5c)
+      ipad = Array.new(block_len, 0x36)
+      opad = Array.new(block_len, 0x5c)
 
       key.bytes.each_with_index { |c, i|
         ipad[i] ^= c
@@ -58,8 +58,8 @@
       }
 
       @key = key.freeze
-      @ipad = ipad.inject('') { |s, c| s << c.chr }.freeze
-      @opad = opad.inject('') { |s, c| s << c.chr }.freeze
+      @ipad = ipad.pack('C*').freeze
+      @opad = opad.pack('C*').freeze
       @md.update(@ipad)
     end
 
@@ -102,7 +102,7 @@
 end
 
 if $0 == __FILE__
-  eval DATA.read, nil, $0, __LINE__+4
+  eval DATA.gets(nil), nil, $0, DATA.lineno
 end
 
 __END__

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]