Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use UnboundMethod#bind_call method instead to improve performance #4588

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/fluent/compat/call_super_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def self.prepended(klass)
def start
super
unless self.started?
@@_super_start[self.class].bind(self).call
@@_super_start[self.class].bind_call(self)
# #super will reset logdev (especially in test), so this warn should be after calling it
log.warn "super was not called in #start: called it forcedly", plugin: self.class
end
Expand All @@ -51,7 +51,7 @@ def before_shutdown
super
unless self.before_shutdown?
log.warn "super was not called in #before_shutdown: calling it forcedly", plugin: self.class
@@_super_before_shutdown[self.class].bind(self).call
@@_super_before_shutdown[self.class].bind_call(self)
end
end

Expand All @@ -68,7 +68,7 @@ def shutdown
super
unless self.shutdown?
log.warn "super was not called in #shutdown: calling it forcedly", plugin: self.class
@@_super_shutdown[self.class].bind(self).call
@@_super_shutdown[self.class].bind_call(self)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/fluent/compat/propagate_default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@ module ClassMethods
CONFIGURABLE_CLASS_METHODS = Fluent::Configurable::ClassMethods

def config_param(name, type = nil, **kwargs, &block)
CONFIGURABLE_CLASS_METHODS.instance_method(:config_param).bind(self).call(name, type, **kwargs, &block)
CONFIGURABLE_CLASS_METHODS.instance_method(:config_param).bind_call(self, name, type, **kwargs, &block)
pparams = propagate_default_params
if kwargs.has_key?(:default) && pparams[name.to_s]
newer = pparams[name.to_s].to_sym
overridden_default_value = kwargs[:default]

CONFIGURABLE_CLASS_METHODS.instance_method(:config_section).bind(self).call(:buffer) do
CONFIGURABLE_CLASS_METHODS.instance_method(:config_section).bind_call(self, :buffer) do
config_set_default newer, overridden_default_value
end
end
end

def config_set_default(name, defval)
CONFIGURABLE_CLASS_METHODS.instance_method(:config_set_default).bind(self).call(name, defval)
CONFIGURABLE_CLASS_METHODS.instance_method(:config_set_default).bind_call(self, name, defval)
pparams = propagate_default_params
if pparams[name.to_s]
newer = pparams[name.to_s].to_sym

CONFIGURABLE_CLASS_METHODS.instance_method(:config_section).bind(self).call(:buffer) do
CONFIGURABLE_CLASS_METHODS.instance_method(:config_section).bind_call(self, :buffer) do
self.config_set_default newer, defval
end
end
Expand Down