1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

18 commits

Author SHA1 Message Date
Akira Matsuda
589dd0f6c9 [Active Support] require_relative => require
This basically reverts 8da30ad6be
2017-10-21 22:48:27 +09:00
Koichi ITO
ac717d65a3 [Active Support] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
Kir Shatrov
72950568dd Use frozen-string-literal in ActiveSupport 2017-07-09 15:08:29 +03:00
Akira Matsuda
8da30ad6be [Active Support] require => require_relative 2017-07-01 18:38:04 +09:00
Akira Matsuda
a43e7706be Privatize unneededly protected methods in Active Support 2016-12-24 11:39:05 +09:00
Xavier Noria
d66e7835be applies new string literal convention in activesupport/lib
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:10:53 +02:00
Alex Kitchens
64cabcd77a [ci skip] Add link to method referenced in ActiveSupport::PerThreadRegistry 2016-06-24 15:14:50 -05:00
David Heinemeier Hansson
748b21db8f Add thread_m/cattr_accessor/reader/writer suite of methods for declaring class and module variables that live per-thread 2015-12-17 14:28:19 +01:00
Matthew Draper
b5384d91a4 Add missing require
Fixes #22311
2015-11-19 11:19:07 +10:30
Matthew Draper
1b6fcae948 Avoid leaking the first relation we call #first on
With the previous implementation, the block passed to
define_singleton_method, which will live forever as the method body,
captures the parameters (args and block) in its enclosure.

For the current_scope registry, that can include an AR::Relation.
2015-10-09 07:09:57 +10:30
Jeremy Kemper
b474d06d5e Perf: save ~9% of object allocations on heavy requests.
The per-thread registry is keyed on the class name, and each request for
the class name returns a new string. This is in the hot path for a lot
of Active Record behavior, so we easily accumulate thousands of repeated
strings.

To fix, we simply cache the key when the class is first extended with
the module.

TODO: Eliminate this module. The per-thread instance concept is common,
but this technique confuses and obfuscates.
2013-12-12 18:53:32 -07:00
Aaron Patterson
5584ddc43d Stop using method missing for singleton delegation.
This saved about 46 array allocations per request on an extremely simple
application.  The delegation happened in the notification subsystem
which is a hotspot, so this should result in even more savings with
larger apps.

Squashed commit of the following:

commit 41eef0d1479526f7de25fd4391d98e61c126d9f5
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Nov 6 16:32:31 2013 -0800

    speed up notifications

commit 586b4a18656f66fb2c518fb8e8fee66a016e8ae6
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Nov 6 16:31:05 2013 -0800

    speed up runtime registry methods

commit b67d074cb4314df9a88438f785868cef77e583d7
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Nov 6 16:28:12 2013 -0800

    change method name and make it public
2013-11-06 16:32:47 -08:00
Francesco Rodriguez
9e82ffcada use define_singleton_method instead of class_eval 2013-04-13 12:14:12 -05:00
Francesco Rodriguez
364f579b8c Add :nodoc: mark to PerThreadRegistry#method_missing [ci skip] 2013-04-13 11:56:19 -05:00
Xavier Noria
e5ef3abdd2 hides the per thread registry instance, and caches singleton methods
Existing code was delegating to the instance with delegate
macro calls, or invoking the instance method to reach
the object and call its instance methods.

But the point is to have a clean class-level interface where
the thread local instance is hidden in the implementation.

References #11c6973.
References #10198.
2013-04-13 17:09:13 +02:00
Xavier Noria
2d42fe7fb5 complete rewrite of the documentation of AS::PerThreadRegistry
* It focuses on how to use it.

* Removes some ambigueties in the original docs about whether the state is stored in the class.

* Documents it provides class-level accessors via method_missing.

* Documents that if the extended class has an initializer, it must accept no arguments.
2013-04-13 08:21:38 +02:00
wangjohn
60a5ac78b0 Using public send instead of send for the PerThreadRegistry module.
Prevents you from accidentally calling a protected method.
2013-04-10 09:56:40 -04:00
wangjohn
e94f024e14 Creating a module so that per thread registries can be easily created as
thread local variables.
2013-04-09 22:27:21 -04:00