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

ruby-changes:28042

From: naruse <ko1@a...>
Date: Thu, 4 Apr 2013 11:35:20 +0900 (JST)
Subject: [ruby-changes:28042] naruse:r40094 (trunk): * ext/openssl/ossl_bn.c (ossl_bn_to_i): Use bn2hex to speed up.

naruse	2013-04-04 11:35:07 +0900 (Thu, 04 Apr 2013)

  New Revision: 40094

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

  Log:
    * ext/openssl/ossl_bn.c (ossl_bn_to_i): Use bn2hex to speed up.
      In general, binary to/from decimal needs extra cost.

  Modified files:
    trunk/ChangeLog
    trunk/ext/openssl/ossl_bn.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40093)
+++ ChangeLog	(revision 40094)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Apr  4 11:33:57 2013  NARUSE, Yui  <naruse@r...>
+
+	* ext/openssl/ossl_bn.c (ossl_bn_to_i): Use bn2hex to speed up.
+	  In general, binary to/from decimal needs extra cost.
+
 Thu Apr  4 07:24:18 2013  Tanaka Akira  <akr@f...>
 
 	* ext/socket/extconf.rb: Specify arguments to test functions.
Index: ext/openssl/ossl_bn.c
===================================================================
--- ext/openssl/ossl_bn.c	(revision 40093)
+++ ext/openssl/ossl_bn.c	(revision 40094)
@@ -226,10 +226,10 @@ ossl_bn_to_i(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_bn.c#L226
 
     GetBN(self, bn);
 
-    if (!(txt = BN_bn2dec(bn))) {
+    if (!(txt = BN_bn2hex(bn))) {
 	ossl_raise(eBNError, NULL);
     }
-    num = rb_cstr_to_inum(txt, 10, Qtrue);
+    num = rb_cstr_to_inum(txt, 16, Qtrue);
     OPENSSL_free(txt);
 
     return num;

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

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