dweiss commented on code in PR #15842:
URL: https://github.com/apache/lucene/pull/15842#discussion_r3022751309
##########
lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/PatternParser.java:
##########
@@ -202,11 +202,11 @@ protected String getExceptionWord(ArrayList<?> ex) {
StringBuilder res = new StringBuilder();
for (int i = 0; i < ex.size(); i++) {
Object item = ex.get(i);
- if (item instanceof String) {
- res.append((String) item);
+ if (item instanceof String s) {
+ res.append(s);
} else {
- if (((Hyphen) item).noBreak != null) {
- res.append(((Hyphen) item).noBreak);
+ if (item instanceof Hyphen h && h.noBreak != null) {
Review Comment:
this is subtly different - the refactored version will silently pass when
item is not a Hyphen (previously, it'd throw ClassCastException. I don't think
this matters.
##########
lucene/monitor/src/java/org/apache/lucene/monitor/RegexpQueryHandler.java:
##########
@@ -94,36 +94,35 @@ public TokenStream wrapTermStream(String field, TokenStream
ts) {
@Override
public QueryTree handleQuery(Query q, TermWeightor termWeightor) {
- if (q instanceof RegexpQuery == false) {
- return null;
+ if (q instanceof RegexpQuery query) {
+ String regexp = parseOutRegexp(query.toString(""));
+ String selected = selectLongestSubstring(regexp);
Review Comment:
I think I liked the previous version better - the short-circuit at the front
instead of the long conditional block.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]