gf2121 commented on PR #12661: URL: https://github.com/apache/lucene/pull/12661#issuecomment-1765964640
> I wonder if extending the Outputs class directly would help, instead of storing data in an opaque byte[]? Yes ,The reuse is exactly what `Outputs` wants to do ! (see this [todo](https://github.com/apache/lucene/blob/6dac2f7afce483a35cb97e4f2022693f4168c496/lucene/core/src/java/org/apache/lucene/util/fst/Outputs.java#L35)). However, It seems that by contract the `Outputs#add` should not modify the input objects (this is not declared in java doc but assumed by callers). I was thinking about adding a new method to `Outputs` like following, WDYT? ``` public Adder<T> adder(T reuse) { return new Adder<>() { T result; @Override public void add(T newOne) { result = Outputs.this.add(result, newOne); } @Override public T result() { return result; } }; } public interface Adder<T> { void add(T newOne); T result(); } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org