lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [lucenenet] theolivenbaum opened a new issue #350: Change ScoreDoc to struct?
Date Wed, 23 Sep 2020 12:19:39 GMT

theolivenbaum opened a new issue #350:
URL: https://github.com/apache/lucenenet/issues/350


   Doing a random check with a memory profiler on the search benchmark test, and it seems
like a lot of the objects being allocated are ScoreDoc instances:
   
   ![image](https://user-images.githubusercontent.com/8791811/94011329-7c009480-fda7-11ea-82de-88d7be9502b6.png)
   
   Is there any good reason to not refactor this as a struct?
   
   The code is so simple that it feels like an easy win to change it to a struct:
   
   ```csharp
       public class ScoreDoc
       {
           public float Score { get; set; } // LUCENENET NOTE: For some reason, this was not
readonly - should it be?
           public int Doc { get; set; } // LUCENENET NOTE: For some reason, this was not readonly
- should it be?
           public int ShardIndex { get; set; } // LUCENENET NOTE: For some reason, this was
not readonly - should it be?
   
           public ScoreDoc(int doc, float score) : this(doc, score, -1) { }
   
           public ScoreDoc(int doc, float score, int shardIndex)
           {
               this.Doc = doc;
               this.Score = score;
               this.ShardIndex = shardIndex;
           }
       }
   ```


----------------------------------------------------------------
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:
users@infra.apache.org



Mime
View raw message