From 5c898ed38cea9fe4780f536314b7a5cbd6903d52 Mon Sep 17 00:00:00 2001 From: Ricardo Trindade Date: Fri, 27 Oct 2023 18:16:54 +0200 Subject: [PATCH] Call detect instead of select..first Detect is slightly faster than select{}.first --- lib/webmock/http_lib_adapters/em_http_request_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/webmock/http_lib_adapters/em_http_request_adapter.rb b/lib/webmock/http_lib_adapters/em_http_request_adapter.rb index c2b2cb92..ec0b89f5 100644 --- a/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +++ b/lib/webmock/http_lib_adapters/em_http_request_adapter.rb @@ -156,7 +156,7 @@ def get_response_cookie(name) raw_cookie = response_header.cookie raw_cookie = [raw_cookie] if raw_cookie.is_a? String - cookie = raw_cookie.select { |c| c.start_with? name }.first + cookie = raw_cookie.detect { |c| c.start_with? name } cookie and cookie.split('=', 2)[1] end