Skip to content

Commit cc7c359

Browse files
committed
Reorder equality so happy path hits Nil#==
For most requests the expectation is that the application will respond to the request and not set the `x-cascade` header. Since the header will be `Nil` in that happy path, we should prefer calling `#==` on the header itself because `String#==` will try to coerce `other` `to_str`, whereas `Nil#==` will not. (`String#==` showed up as ~2.5% in a profile, and this eliminates it)
1 parent dc45cb8 commit cc7c359

File tree

1 file changed

+1
-1
lines changed
  • actionpack/lib/action_dispatch/journey

1 file changed

+1
-1
lines changed

actionpack/lib/action_dispatch/journey/router.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def serve(req)
4343

4444
_, headers, _ = response = route.app.serve(req)
4545

46-
if "pass" == headers[Constants::X_CASCADE]
46+
if headers[Constants::X_CASCADE] == "pass"
4747
req.script_name = script_name
4848
req.path_info = path_info
4949
req.path_parameters = set_params

0 commit comments

Comments
 (0)