donnerpeter commented on a change in pull request #2207:
URL: https://github.com/apache/lucene-solr/pull/2207#discussion_r560179093
##########
File path:
lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SpellChecker.java
##########
@@ -24,22 +24,24 @@
*/
public class SpellChecker {
private final Dictionary dictionary;
- private final ThreadLocal<Stemmer> stemmer;
- private final ThreadLocal<BytesRef> scratch =
ThreadLocal.withInitial(BytesRef::new);
+ private final BytesRef scratch = new BytesRef();
- public SpellChecker(Dictionary dictionary) {
+ private SpellChecker(Dictionary dictionary) {
Review comment:
Yes, I've just decided that the static method would be better, as it'd
preserve the thread-safety of the API and avoid dirty thread-locals. If needed,
the constructor can be made public later, but for now in my 3M-word test see
almost no difference. If you insist I can make the constructor public, it just
doesn't feel right to me when a supposedly pure function is thread-unsafe, and
I've seen bugs caused by such assumptions.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]