Environment::set() is slow
Hi!
In our app we (ab)use Environment::set() when bootstrapping to set all of our site's configuration. We set some defaults, and then depending on our environment (prod/test/dev) we overwrite some of those.
I was just trying to improve my app's performance and I've found that Environment::set() uses Set::merge() which is kinda slow.
Sometimes you want to set some configuration overwriting the existing values. Perhaps I'm misusing this class.
Example:
<?php
// This is slow
Environment::set(true, ['assets' => $foo + Environment::get('assets')]);
// This is fast
$bar = $foo + Environment::get('assets');
Environment::set(true, ['assets' => null]);
Environment::set(true, ['assets' => $bar]);
Initial set has been minimally optimized in 1e7b3271342576e1b7ce76a4317b41c955736945. Set::merge seems already pretty optimized, but maybe someone might want to give it a try. @fedeisas Benchmarks showing the differences (and where time is spent) between the two cases outlined in your report would help.