Optimise Keyword.delete/2 and friends (#6564)
Optimise Keyword.delete/2 and friends (#6564)

This optimises all functions similar to Keyword.delete/2:

  * Keyword.delete/2
  * Keyword.delete/3
  * Keyword.delete_first/2

The changes are:

  * use by-hand recursion instead of non-BIF :lists calls
  * in case we end up not deleting a value, use trow-catch to return the
    original list unmodified (this significantly lowers memory use)
  * build the result through body recursion, this way when we unwind the stack
    we free all the data and leave no garbage behind for the GC.

In benchmarks, the new Keyword.delete/2 functions is twice as fast as the old
implementation. Since it's frequently used internally by the Keyword module (for
example in Keyword.put/3) this improves the efficiency of all those functions.

Benchmark reference: https://gist.github.com/michalmuskala/f7f38151495acf7ead131f80271359e7
kelvinst/elixir,beedub/elixir,ggcampinho/elixir,antipax/elixir,kelvinst/elixir,gfvcastro/elixir,elixir-lang/elixir,kimshrier/elixir,joshprice/elixir,pedrosnk/elixir,pedrosnk/elixir,antipax/elixir,gfvcastro/elixir,lexmag/elixir,ggcampinho/elixir,kimshrier/elixir,lexmag/elixir,michalmuskala/elixir,beedub/elixir