lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [lucenenet] aaron-meyers commented on issue #224: https://issues.apache.org/jira/browse/LUCENENET-607
Date Mon, 04 Mar 2019 15:02:05 GMT
aaron-meyers commented on issue #224: https://issues.apache.org/jira/browse/LUCENENET-607
URL: https://github.com/apache/lucenenet/pull/224#issuecomment-469284006
 
 
   This is great, we've run into this issue in production with Lucene.Net but hadn't been
able to isolate a repro.
   
   One minor comment: when possible, avoid using static constructors and instead initialize
static fields directly (using private static helper methods if needed).
   
   e.g. instead of
   
           public static readonly int GOOD_FAST_HASH_SEED;
   
           static StringHelper()
           {
               ...
               GOOD_FAST_HASH_SEED = x;
           }
   
   use this pattern:
   
           public static readonly int GOOD_FAST_HASH_SEED = InitializeHashSeed();
   
           private static int InitializeHashSeed()
           {
               ...
               return x;
           }
   
   It may look like these are equivalent but in fact they are not. Using the latter pattern
gives the CLR more flexibility in how it initializes the class.
   
   More details:
   https://stackoverflow.com/questions/10465961/potential-pitfalls-with-static-constructors-in-c-sharp
   http://csharpindepth.com/Articles/BeforeFieldInit

----------------------------------------------------------------
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


With regards,
Apache Git Services

Mime
View raw message