See https://github.com/hibernate/hibernate-search/commit/1b3c001011f10b410b6f8b208e5ba58cf9b15fc9 and previous commits
The main benefit is that we would also be able to convert arrays to iterable (instead of just iterators), which would make client code simpler.
Instead of this:
{code} Iterator<T> it = CollectionHelper.iteratorFromArray(array); while ( it.hasNext() ) { T obj = it.next(); // .. do stuff } {code}
We'd have this:
{code} for ( T obj : CollectionHelper.iterableFromArray(array) ) { // .. do stuff } {code}
I have confirmed that in the code I'm suggesting, calls to ArrayAccessor get inlined by the JVM, so there's proably little to no overhead.
Other than that, well... The code is a bit less redundant, since we clearly separate concerns between the ArrayAccessor and the Iterable/Iterator implementations. |
|