Skip to content

Commit

Permalink
Improve formatter performance
Browse files Browse the repository at this point in the history
  • Loading branch information
vbreuss committed Nov 16, 2024
1 parent 1c04f95 commit 60e0924
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions Source/Testably.Expectations/Core/Constraints/ConstraintResult.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;

namespace Testably.Expectations.Core.Constraints;

Expand Down Expand Up @@ -166,21 +165,10 @@ internal override ConstraintResult UpdateExpectationText(
/// </summary>
public class Failure : ConstraintResult
{
private readonly StringBuilder _resultBuilder = new();

/// <summary>
/// A human-readable representation of the reason for the failure.
/// </summary>
public string ResultText
{
get
{
_resultText ??= _resultBuilder.ToString();
return _resultText;
}
}

private string? _resultText;
public string ResultText { get; }

/// <summary>
/// Initializes a new instance of <see cref="ConstraintResult.Failure" />.
Expand All @@ -193,25 +181,7 @@ public Failure(
expectationText,
furtherProcessingStrategy)
{
_resultText = resultText;
}

/// <summary>
/// Initializes a new instance of <see cref="ConstraintResult.Failure" />.
/// </summary>
public Failure(
string expectationText,
FurtherProcessing furtherProcessingStrategy = FurtherProcessing.Continue)
: base(
expectationText,
furtherProcessingStrategy)
{
}

public Failure AppendResult(string result)
{
_resultBuilder.Append(result);
return this;
ResultText = resultText;
}

/// <inheritdoc cref="ConstraintResult.CombineWith(string, string)" />
Expand Down

0 comments on commit 60e0924

Please sign in to comment.