Slide 46
Slide 46 text
palkan_tula
palkan RubyKaigi‘20
def call(val)
status, headers, body = 200, {}, ""
case val
in [String => body]
[status, headers, [body]]
in [Integer => status]
[status, headers, [body]]
in [Integer, String] => response
[response[0], headers, [response[1]]]
in [Integer, Hash, String] => response
headers.merge!(response[1])
[response[0], headers, [response[2]]]
end
end
46
Comparison:
transpiled (last pattern): 1162200.7 i/s
baseline (last pattern): 799739.5 i/s - 1.45x slower
Transpiled != Slow