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

ruby-changes:19649

From: emboss <ko1@a...>
Date: Sun, 22 May 2011 23:27:09 +0900 (JST)
Subject: [ruby-changes:19649] emboss:r31694 (trunk): * ext/openssl/ossl_asn1.c: Instead of rb_intern use static symbols to

emboss	2011-05-22 23:27:02 +0900 (Sun, 22 May 2011)

  New Revision: 31694

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

  Log:
    * ext/openssl/ossl_asn1.c: Instead of rb_intern use static symbols to
    improve performance.

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31693)
+++ ChangeLog	(revision 31694)
@@ -1,3 +1,8 @@
+Sun May 22 23:24:02 2011  Martin Bosslet  <Martin.Bosslet@g...>
+
+	* ext/openssl/ossl_asn1.c: Instead of rb_intern use static symbols to
+	improve performance.
+
 Sun May 22 21:56:51 2011  Martin Bosslet  <Martin.Bosslet@g...>
 
 	* ext/openssl/ossl_asn1.c: Use OpenSSL constants V_ASN1_xxx instead of
Index: ext/openssl/ossl_asn1.c
===================================================================
--- ext/openssl/ossl_asn1.c	(revision 31693)
+++ ext/openssl/ossl_asn1.c	(revision 31694)
@@ -158,17 +158,17 @@
 /*
  * ASN1 module
  */
-#define ossl_asn1_get_value(o)           rb_attr_get((o),rb_intern("@value"))
-#define ossl_asn1_get_tag(o)             rb_attr_get((o),rb_intern("@tag"))
-#define ossl_asn1_get_tagging(o)         rb_attr_get((o),rb_intern("@tagging"))
-#define ossl_asn1_get_tag_class(o)       rb_attr_get((o),rb_intern("@tag_class"))
-#define ossl_asn1_get_infinite_length(o) rb_attr_get((o),rb_intern("@infinite_length"))
+#define ossl_asn1_get_value(o)           rb_attr_get((o),sivVALUE)
+#define ossl_asn1_get_tag(o)             rb_attr_get((o),sivTAG)
+#define ossl_asn1_get_tagging(o)         rb_attr_get((o),sivTAGGING)
+#define ossl_asn1_get_tag_class(o)       rb_attr_get((o),sivTAG_CLASS)
+#define ossl_asn1_get_infinite_length(o) rb_attr_get((o),sivINFINITE_LENGTH)
 
-#define ossl_asn1_set_value(o,v)           rb_iv_set((o),"@value",(v))
-#define ossl_asn1_set_tag(o,v)             rb_iv_set((o),"@tag",(v))
-#define ossl_asn1_set_tagging(o,v)         rb_iv_set((o),"@tagging",(v))
-#define ossl_asn1_set_tag_class(o,v)       rb_iv_set((o),"@tag_class",(v))
-#define ossl_asn1_set_infinite_length(o,v) rb_iv_set((o),"@infinite_length",(v))
+#define ossl_asn1_set_value(o,v)           rb_ivar_set((o),sivVALUE,(v))
+#define ossl_asn1_set_tag(o,v)             rb_ivar_set((o),sivTAG,(v))
+#define ossl_asn1_set_tagging(o,v)         rb_ivar_set((o),sivTAGGING,(v))
+#define ossl_asn1_set_tag_class(o,v)       rb_ivar_set((o),sivTAG_CLASS,(v))
+#define ossl_asn1_set_infinite_length(o,v) rb_ivar_set((o),sivINFINITE_LENGTH,(v))
 
 VALUE mASN1;
 VALUE eASN1Error;
@@ -194,6 +194,7 @@
 
 static ID sIMPLICIT, sEXPLICIT;
 static ID sUNIVERSAL, sAPPLICATION, sCONTEXT_SPECIFIC, sPRIVATE;
+static ID sivVALUE, sivTAG, sivTAG_CLASS, sivTAGGING, sivINFINITE_LENGTH, sivUNUSED_BITS;
 
 /*
  * Ruby to ASN1 converters
@@ -515,7 +516,7 @@
 	free_func = ASN1_INTEGER_free;
 	break;
     case V_ASN1_BIT_STRING:
-        rflag = rb_attr_get(obj, rb_intern("@unused_bits"));
+        rflag = rb_attr_get(obj, sivUNUSED_BITS);
         flag = NIL_P(rflag) ? -1 : NUM2INT(rflag);
 	ptr = obj_to_asn1bstr(value, flag);
 	free_func = ASN1_BIT_STRING_free;
@@ -862,7 +863,7 @@
                 }
             }
 	    if(tag == V_ASN1_BIT_STRING){
-		rb_iv_set(asn1data, "@unused_bits", LONG2NUM(flag));
+		rb_ivar_set(asn1data, sivUNUSED_BITS, LONG2NUM(flag));
 	    }
 	}
 	else{
@@ -1312,6 +1313,13 @@
     sEXPLICIT = rb_intern("EXPLICIT");
     sIMPLICIT = rb_intern("IMPLICIT");
 
+    sivVALUE = rb_intern("@value");
+    sivTAG = rb_intern("@tag");
+    sivTAGGING = rb_intern("@tagging");
+    sivTAG_CLASS = rb_intern("@tag_class");
+    sivINFINITE_LENGTH = rb_intern("@infinite_length");
+    sivUNUSED_BITS = rb_intern("@unused_bits");
+
     /*
      * Document-module: OpenSSL::ASN1
      *

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

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