rails/activesupport
Jean Boussier 1962e8d735 class_attribute: reduce reliance on define_method
Full benchmark: https://gist.github.com/casperisfine/539e310eadd0cb6
Followup: https://github.com/rails/rails/pull/37903

Instead of always redefining a bmethod on assignment,
if the reciever already has its own bmethod, we just
update the local variable.

This wasn't really considered before because class attributes
are mostly meant for configuration, so not really expected
to be changed at runtime, but it can happen.

This is 10 to 17x faster to assign a class attributes:

```
interpreter:
                 old:  1834149.6 i/s
                 new: 17722346.6 i/s - 9.66x  faster
yjit:
                 old:  2561173.8 i/s
                 new: 43004422.5 i/s - 16.79x  faster
```

The difference is even bigger if something is redefining
`method_added` events, e.g. sorbet...

All other cases are unchanged in performance, except definition
that is marginally faster.

One downside however is that generated accessors source location
will no longer point to the `class_attribute` callsite.
2024-08-27 17:31:00 +02:00
..
bin Remove `AS::Multibyte`'s unicode table 2018-02-20 03:58:22 +09:00
lib class_attribute: reduce reliance on define_method 2024-08-27 17:31:00 +02:00
test class_attribute: reduce reliance on define_method 2024-08-27 17:31:00 +02:00
.gitignore Clean up and consolidate .gitignores 2018-02-17 14:26:19 -08:00
CHANGELOG.md ActiveSupport::ErrorReporter#report assigns a backtrace to unraised exceptions 2024-08-23 10:17:56 +02:00
MIT-LICENSE Remove Copyright years (#47467) 2023-02-23 11:38:16 +01:00
README.rdoc 🔗 Remove RDoc auto-link from Rails module everywhere 2023-06-23 10:49:30 +09:00
Rakefile Enable Rails minitest plugin in our rake tasks 2024-05-23 16:16:37 +00:00
activesupport.gemspec Declare Active Support dependency on securerandom >= 0.3 2024-08-01 08:41:12 +02:00

README.rdoc

= Active Support -- Utility classes and Ruby extensions from \Rails

Active Support is a collection of utility classes and standard library
extensions that were found useful for the \Rails framework. These additions
reside in this package so they can be loaded as needed in Ruby projects
outside of \Rails.

You can read more about the extensions in the {Active Support Core Extensions}[https://guides.rubyonrails.org/active_support_core_extensions.html] guide.

== Download and installation

The latest version of Active Support can be installed with RubyGems:

  $ gem install activesupport

Source code can be downloaded as part of the \Rails project on GitHub:

* https://github.com/rails/rails/tree/main/activesupport


== License

Active Support is released under the MIT license:

* https://opensource.org/licenses/MIT


== Support

API documentation is at:

* https://api.rubyonrails.org

Bug reports for the Ruby on \Rails project can be filed here:

* https://github.com/rails/rails/issues

Feature requests should be discussed on the rails-core mailing list here:

* https://discuss.rubyonrails.org/c/rubyonrails-core