thrift-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kcl...@apache.org
Subject svn commit: r675053 - in /incubator/thrift/trunk/lib/rb: lib/thrift/struct.rb lib/thrift/types.rb spec/types_spec.rb
Date Tue, 08 Jul 2008 23:30:13 GMT
Author: kclark
Date: Tue Jul  8 16:30:13 2008
New Revision: 675053

URL: http://svn.apache.org/viewvc?rev=675053&view=rev
Log:
rb: Check Thrift.type_checking earlier for a performance boost [THRIFT-55]

Author: Kevin Ballard <kevin@rapleaf.com>

Modified:
    incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
    incubator/thrift/trunk/lib/rb/lib/thrift/types.rb
    incubator/thrift/trunk/lib/rb/spec/types_spec.rb

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb?rev=675053&r1=675052&r2=675053&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb Tue Jul  8 16:30:13 2008
@@ -6,7 +6,7 @@
     def initialize(d={})
       each_field do |fid, type, name, default|
         value = d.delete(name.to_s) { d.delete(name.to_sym) { default.dup rescue default
} }
-        Thrift.check_type(value, type)
+        Thrift.check_type(value, type) if Thrift.type_checking
         instance_variable_set("@#{name}", value)
       end
       raise Exception, "Unknown keys given to #{self.class}.new: #{d.keys.join(", ")}" unless
d.empty?
@@ -72,7 +72,7 @@
       fields.each do |field|
         klass.send :attr_reader, field
         klass.send :define_method, "#{field}=" do |value|
-          Thrift.check_type(value, klass::FIELDS.values.find { |f| f[:name].to_s == field.to_s
}[:type] )
+          Thrift.check_type(value, klass::FIELDS.values.find { |f| f[:name].to_s == field.to_s
}[:type] ) if Thrift.type_checking
           instance_variable_set("@#{field}", value)
         end
       end

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/types.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/types.rb?rev=675053&r1=675052&r2=675053&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/types.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/types.rb Tue Jul  8 16:30:13 2008
@@ -26,7 +26,7 @@
   end
 
   def self.check_type(value, type)
-    return unless Thrift.type_checking and not value.nil?
+    return if value.nil?
     klasses = case type
               when Types::VOID
                 NilClass

Modified: incubator/thrift/trunk/lib/rb/spec/types_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/types_spec.rb?rev=675053&r1=675052&r2=675053&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/types_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/types_spec.rb Tue Jul  8 16:30:13 2008
@@ -47,6 +47,7 @@
     end
 
     it "should be disabled when Thrift.type_checking = false" do
+      pending "disabled, parents should check Thrift.type_checking"
       Thrift.type_checking = false
       lambda { Thrift.check_type(3, Types::STRING) }.should_not raise_error(TypeError)
     end



Mime
View raw message