You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Lucene/Solr QA (JIRA)" <ji...@apache.org> on 2018/09/05 20:59:00 UTC

[jira] [Commented] (LUCENE-8487) Code Optimizations in FieldType

    [ https://issues.apache.org/jira/browse/LUCENE-8487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604934#comment-16604934 ] 

Lucene/Solr QA commented on LUCENE-8487:
----------------------------------------

| (x) *{color:red}-1 overall{color}* |
\\
\\
|| Vote || Subsystem || Runtime || Comment ||
|| || || || {color:brown} Prechecks {color} ||
| {color:red}-1{color} | {color:red} test4tests {color} | {color:red}  0m  0s{color} | {color:red} The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch. {color} |
|| || || || {color:brown} master Compile Tests {color} ||
| {color:green}+1{color} | {color:green} compile {color} | {color:green}  0m 18s{color} | {color:green} master passed {color} |
|| || || || {color:brown} Patch Compile Tests {color} ||
| {color:green}+1{color} | {color:green} compile {color} | {color:green}  0m 17s{color} | {color:green} the patch passed {color} |
| {color:green}+1{color} | {color:green} javac {color} | {color:green}  0m 17s{color} | {color:green} the patch passed {color} |
| {color:green}+1{color} | {color:green} Release audit (RAT) {color} | {color:green}  0m 17s{color} | {color:green} the patch passed {color} |
| {color:green}+1{color} | {color:green} Check forbidden APIs {color} | {color:green}  0m 17s{color} | {color:green} the patch passed {color} |
| {color:green}+1{color} | {color:green} Validate source patterns {color} | {color:green}  0m 17s{color} | {color:green} the patch passed {color} |
|| || || || {color:brown} Other Tests {color} ||
| {color:green}+1{color} | {color:green} unit {color} | {color:green} 10m 37s{color} | {color:green} core in the patch passed. {color} |
| {color:black}{color} | {color:black} {color} | {color:black} 12m 36s{color} | {color:black} {color} |
\\
\\
|| Subsystem || Report/Notes ||
| JIRA Issue | LUCENE-8487 |
| JIRA Patch URL | https://issues.apache.org/jira/secure/attachment/12938509/LUCENE-8487.patch |
| Optional Tests |  compile  javac  unit  ratsources  checkforbiddenapis  validatesourcepatterns  |
| uname | Linux lucene1-us-west 4.4.0-130-generic #156~14.04.1-Ubuntu SMP Thu Jun 14 13:51:47 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux |
| Build tool | ant |
| Personality | /home/jenkins/jenkins-slave/workspace/PreCommit-LUCENE-Build/sourcedir/dev-tools/test-patch/lucene-solr-yetus-personality.sh |
| git revision | master / b4a1548 |
| ant | version: Apache Ant(TM) version 1.9.3 compiled on July 24 2018 |
| Default Java | 1.8.0_172 |
|  Test Results | https://builds.apache.org/job/PreCommit-LUCENE-Build/86/testReport/ |
| modules | C: lucene/core U: lucene/core |
| Console output | https://builds.apache.org/job/PreCommit-LUCENE-Build/86/console |
| Powered by | Apache Yetus 0.7.0   http://yetus.apache.org |


This message was automatically generated.



> Code Optimizations in FieldType
> -------------------------------
>
>                 Key: LUCENE-8487
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8487
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: core/other
>            Reporter: Namgyu Kim
>            Priority: Minor
>              Labels: optimization
>         Attachments: LUCENE-8487.patch
>
>
> 1) Delete unnecessary _if statement_.
> {code:java}
> // Line 281 method
> public void setDimensions(int dimensionCount, int dimensionNumBytes) {
>   ...
>   if (dimensionCount == 0) {
>     if (dimensionNumBytes != 0) {
>       throw new IllegalArgumentException("when dimensionCount is 0, dimensionNumBytes must 0; got " + dimensionNumBytes);
>     }
>   } else if (dimensionNumBytes == 0) {
>     if (dimensionCount != 0) {
>       throw new IllegalArgumentException("when dimensionNumBytes is 0, dimensionCount must 0; got " + dimensionCount);
>     }
>   }
>   ...
> }{code}
> In this code, we can see that the following _if statement_ is unnecessary.
> {code:java}
> if (dimensionCount != 0) {
>   throw new IllegalArgumentException("when dimensionNumBytes is 0, dimensionCount must 0; got " + dimensionCount);
> }{code}
> Because it is a condition that is already processed in the upper _if statement_
>  (if dimensionCount == 0)
> So I made the following code.
> {code:java}
> // Line 281 method
> public void setDimensions(int dimensionCount, int dimensionNumBytes) {
>   ...
>   if (dimensionCount == 0) {
>     if (dimensionNumBytes != 0) {
>       throw new IllegalArgumentException("when dimensionCount is 0, dimensionNumBytes must 0; got " + dimensionNumBytes);
>     }
>   } else if (dimensionNumBytes == 0) {
>     throw new IllegalArgumentException("when dimensionNumBytes is 0, dimensionCount must 0; got " + dimensionCount);
>   }
>   ...
> }
> {code}
> 2) Simplify _if statement_
> {code:java}
> // Line 417 method
> public boolean equals(Object obj) {
>   if (this == obj) return true;
>   if (obj == null) return false;
>   ...
>   if (storeTermVectors != other.storeTermVectors) return false;
>   if (stored != other.stored) return false;
>   if (tokenized != other.tokenized) return false;
>   return true;
> }
> {code}
> The final _if statement_ can be simplified.
> {code:java}
> // Line 417 method
> public boolean equals(Object obj) {
>   if (this == obj) return true;
>   if (obj == null) return false;
>   ...
>   if (storeTermVectors != other.storeTermVectors) return false;
>   if (stored != other.stored) return false;
>   return tokenized == other.tokenized;
> }{code}
> But I worry that change will hinder readability.
> For that reason, if it is not good, I will not reflect it in the patch.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org