use max instead of sort_by { |p| p.size }.last

`sort_by { |p| p.size }.last` is less readable compared to just using the `max` method

I believe this does basicall the exact same thing, ontop of being much faster in my micro benchmark.

The old method was, something like, 8 times slower.
GSoC/Meterpreter_Web_Console
Kent 'picat' Gruber 2018-09-14 11:19:16 -04:00
parent 2dcfdcbdc4
commit c71078a381
2 changed files with 2 additions and 3 deletions

View File

@ -259,7 +259,7 @@ module Auxiliary::Web
if payloads
payload = payloads.select { |p|
element.altered_value.include?( p )
}.sort_by { |p| p.size }.last
}.max
end
end

View File

@ -55,8 +55,7 @@ module Analysis::Timing
timeout = opts[:delay]
seed = p.altered_value.dup
payload = fuzzer.payloads.select{ |pl| seed.include?( pl ) }.
sort_by { |p2| p2.size }.last
payload = fuzzer.payloads.select{ |pl| seed.include?( pl ) }.max
# 1st pass, make sure the webapp is responsive
if_responsive do