Skip to content

Instantly share code, notes, and snippets.

@jbn
Created September 18, 2015 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbn/c447a98ff5718f9d6730 to your computer and use it in GitHub Desktop.
Save jbn/c447a98ff5718f9d6730 to your computer and use it in GitHub Desktop.
My justification for rewriting OAuth.jl's oauth_serialize_url_parameters
function method_a(options)
parameterstring = ""
keyssorted = sort!(collect(keys(options)))
for key in keyssorted
parameterstring *= "$key=$(options["$key"])&"
end
chop(parameterstring)
end
function method_b(options)
join(
["$key=$(options[key])" for key in sort!(collect(keys(options)))],
"&"
)
end
params = Dict([randstring(10) => randstring(40) for _ in 1:10])
# Warm up...
method_a(params)
method_b(params)
@assert method_a(params) == method_b(params)
sleep(1) # To semi-ensure JIT is done.
@time method_a(params)
@time method_b(params);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment