Skip to content

Commit

Permalink
Avoid loading strings unless needed
Browse files Browse the repository at this point in the history
This was between 5ms -> 15ms during VS startup on the UI thread.
  • Loading branch information
davkean committed Jul 22, 2024
1 parent cc6c8cd commit 79e9dfa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Nerdbank.Streams/MultiplexingStream.Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,14 @@ public bool FaultOpenChannelsOnStreamDisposal
/// <returns>This instance if already frozen, otherwise a frozen copy.</returns>
public Options GetFrozenCopy() => this.IsFrozen ? this : new Options(this, frozen: true);

private void ThrowIfFrozen() => Verify.Operation(!this.IsFrozen, Strings.Frozen);
private void ThrowIfFrozen()
{
// Avoid loading string unless needed
if (this.IsFrozen)
{
Verify.FailOperation(Strings.Frozen);
}
}
}
}
}

0 comments on commit 79e9dfa

Please sign in to comment.