Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6571

Show
Ignore:
Timestamp:
04/24/07 16:58:24 (1 year ago)
Author:
david
Message:

Improved performance by relying less on exception raising #8159 [Blaine]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-stable/activerecord/CHANGELOG

    r6471 r6571  
    44 
    55* SQLite: binary escaping works with $KCODE='u'.  #7862 [tsuka] 
     6 
     7* Improved cloning performance by relying less on exception raising #8159 [Blaine] 
    68 
    79 
  • branches/1-2-stable/activerecord/lib/active_record/base.rb

    r6471 r6571  
    21602160      def clone_attribute_value(reader_method, attribute_name) 
    21612161        value = send(reader_method, attribute_name) 
    2162         value.clone 
     2162 
     2163        case value 
     2164        when nil, Fixnum, true, false 
     2165          value 
     2166        else 
     2167          value.clone 
     2168        end 
    21632169      rescue TypeError, NoMethodError 
    21642170        value 
  • branches/1-2-stable/activesupport/CHANGELOG

    r6428 r6571  
    22 
    33* Update Dependencies to ignore constants inherited from ancestors. Closes #6951. [Nicholas Seckar] 
     4 
     5* Improved multibyte performance by relying less on exception raising #8159 [Blaine] 
    46 
    57 
  • branches/1-2-stable/activesupport/lib/active_support/multibyte/chars.rb

    r5980 r6571  
    4444    # Create a new Chars instance. 
    4545    def initialize(str) 
    46       @string = (str.string rescue str) 
     46      @string = str.respond_to?(:string) ? str.string : str 
    4747    end 
    4848     
     
    7171      begin 
    7272        # Simulate methods with a ! at the end because we can't touch the enclosed string from the handlers. 
    73         if m.to_s =~ /^(.*)\!$/ 
     73        if m.to_s =~ /^(.*)\!$/ && handler.respond_to?($1) 
    7474          result = handler.send($1, @string, *a, &b) 
    7575          if result == @string 
     
    7878            @string.replace result 
    7979          end 
     80        elsif handler.respond_to?(m) 
     81          result = handler.send(m, @string, *a, &b) 
    8082        else 
    81           result = handler.send(m, @string, *a, &b) 
     83          result = @string.send(m, *a, &b) 
    8284        end 
    83       rescue NoMethodError 
    84         result = @string.send(m, *a, &b) 
    8585      rescue Handlers::EncodingError 
    8686        @string.replace handler.tidy_bytes(@string) 
  • trunk/activerecord/CHANGELOG

    r6549 r6571  
    11*SVN* 
     2 
     3* Improved cloning performance by relying less on exception raising #8159 [Blaine] 
    24 
    35* Added ActiveRecord::Base.inspect to return a column-view like #<Post id:integer, title:string, body:text> [DHH] 
  • trunk/activerecord/lib/active_record/base.rb

    r6549 r6571  
    22322232      def clone_attribute_value(reader_method, attribute_name) 
    22332233        value = send(reader_method, attribute_name) 
    2234         value.clone 
     2234 
     2235        case value 
     2236        when nil, Fixnum, true, false 
     2237          value 
     2238        else 
     2239          value.clone 
     2240        end 
    22352241      rescue TypeError, NoMethodError 
    22362242        value 
  • trunk/activesupport/CHANGELOG

    r6546 r6571  
    11*SVN* 
     2 
     3* Improved multibyte performance by relying less on exception raising #8159 [Blaine] 
    24 
    35* Use XSD-compatible type names for Hash#to_xml and make the converters extendable #8047 [Tim Pope] 
  • trunk/activesupport/lib/active_support/multibyte/chars.rb

    r6044 r6571  
    4444    # Create a new Chars instance. 
    4545    def initialize(str) 
    46       @string = (str.string rescue str) 
     46      @string = str.respond_to?(:string) ? str.string : str 
    4747    end 
    4848     
     
    7171      begin 
    7272        # Simulate methods with a ! at the end because we can't touch the enclosed string from the handlers. 
    73         if m.to_s =~ /^(.*)\!$/ 
     73        if m.to_s =~ /^(.*)\!$/ && handler.respond_to?($1) 
    7474          result = handler.send($1, @string, *a, &b) 
    7575          if result == @string 
     
    7878            @string.replace result 
    7979          end 
     80        elsif handler.respond_to?(m) 
     81          result = handler.send(m, @string, *a, &b) 
    8082        else 
    81           result = handler.send(m, @string, *a, &b) 
     83          result = @string.send(m, *a, &b) 
    8284        end 
    83       rescue NoMethodError 
    84         result = @string.send(m, *a, &b) 
    8585      rescue Handlers::EncodingError 
    8686        @string.replace handler.tidy_bytes(@string)