Skip to content

A platform for community discussion. Free, open, simple.

PERF: avoid regex for hot path

Sam Saffron586dfcc795b4
diff --git a/lib/freedom_patches/zeitwerk.rb b/lib/freedom_patches/zeitwerk.rb
index 4c68ede4e5d..9cd102aac00 100644
--- a/lib/freedom_patches/zeitwerk.rb
+++ b/lib/freedom_patches/zeitwerk.rb
@@ -18,8 +18,8 @@ module ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector
}
def self.camelize(basename, abspath)
- return basename.camelize if abspath =~ /onceoff\.rb$/
- return 'Jobs' if abspath =~ /jobs\/base\.rb$/
+ return basename.camelize if abspath.ends_with?("onceoff.rb")
+ return 'Jobs' if abspath.ends_with?("jobs/base.rb")
CUSTOM_PATHS.fetch(basename, basename.camelize)
end
end