From c7f23fa3db35fba6b0db7105fdc3f46ac5e3a40d Mon Sep 17 00:00:00 2001 From: Shad Storhaug Date: Mon, 29 Jun 2020 08:12:16 +0700 Subject: [PATCH] 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 0664cfc011..25515b652a 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 @@ public override string ToString() { 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(); } } }