You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2020/06/30 21:50:48 UTC
[lucenenet] 12/27:
Lucene.Net.TestFramework.Search.RandomSimilarityProvider::ToString(): Use
StringBuilder for better efficiency (#295, #261)
This is an automated email from the ASF dual-hosted git repository.
nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit c7f23fa3db35fba6b0db7105fdc3f46ac5e3a40d
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Mon Jun 29 08:12:16 2020 +0700
Lucene.Net.TestFramework.Search.RandomSimilarityProvider::ToString(): Use StringBuilder for better efficiency (#295, #261)
---
.../Search/RandomSimilarityProvider.cs | 26 +++++++++++-----------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/Lucene.Net.TestFramework/Search/RandomSimilarityProvider.cs b/src/Lucene.Net.TestFramework/Search/RandomSimilarityProvider.cs
index 0664cfc..25515b6 100644
--- a/src/Lucene.Net.TestFramework/Search/RandomSimilarityProvider.cs
+++ b/src/Lucene.Net.TestFramework/Search/RandomSimilarityProvider.cs
@@ -1,8 +1,8 @@
using J2N.Collections.Generic.Extensions;
using Lucene.Net.Search.Similarities;
-using Lucene.Net.Support;
using System;
using System.Collections.Generic;
+using System.Text;
using Debug = Lucene.Net.Diagnostics.Debug; // LUCENENET NOTE: We cannot use System.Diagnostics.Debug because those calls will be optimized out of the release!
namespace Lucene.Net.Search
@@ -140,21 +140,21 @@ namespace Lucene.Net.Search
{
lock (this)
{
- string coordMethod;
+ // LUCENENET: Use StringBuilder for better efficiency
+ var sb = new StringBuilder();
+ sb.Append(nameof(RandomSimilarityProvider));
+ sb.Append("(queryNorm=");
+ sb.Append(shouldQueryNorm);
+ sb.Append(",coord=");
if (coordType == 0)
- {
- coordMethod = "no";
- }
+ sb.Append("no");
else if (coordType == 1)
- {
- coordMethod = "yes";
- }
+ sb.Append("yes");
else
- {
- coordMethod = "crazy";
- }
- return "RandomSimilarityProvider(queryNorm=" + shouldQueryNorm + ",coord=" + coordMethod + "): " +
- string.Format(J2N.Text.StringFormatter.InvariantCulture, "{0}", previousMappings);
+ sb.Append("crazy");
+ sb.Append("): ");
+ sb.AppendFormat(J2N.Text.StringFormatter.InvariantCulture, "{0}", previousMappings);
+ return sb.ToString();
}
}
}