-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1012 from Erarndt/avoidBoolBoxing
Cache boxed bool values to reduce allocation overhead
- Loading branch information
Showing
2 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.Threading | ||
{ | ||
internal static class Boxed | ||
{ | ||
/// <summary> | ||
/// Returns an object containing <see langword="true"/>. | ||
/// </summary> | ||
public static readonly object True = true; | ||
|
||
/// <summary> | ||
/// Returns an object containing <see langword="false"/>. | ||
/// </summary> | ||
public static readonly object False = false; | ||
|
||
/// <summary> | ||
/// Returns an object containing specified value. | ||
/// </summary> | ||
public static object Box(bool value) | ||
{ | ||
return value ? True : False; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters