From the 3.2.16 source:
```ruby
  def index_by
    return to_enum :index_by unless block_given?
    Hash[map { |elem| [yield(elem), elem] }]
  end
```

So looks like it builds up pairs and does one conversion to Hash