Skip to content

Ensure that the buffer is cleared when disposed#12

Merged
mwadams merged 3 commits intomainfrom
feature/11-valuestringbuilder-buffer-clearing
Jul 7, 2025
Merged

Ensure that the buffer is cleared when disposed#12
mwadams merged 3 commits intomainfrom
feature/11-valuestringbuilder-buffer-clearing

Conversation

@mwadams
Copy link
Contributor

@mwadams mwadams commented Jul 7, 2025

Add an overload to ReturnRentedBuffer() which allows you to clear the buffer.

Add an overload to ReturnRentedBuffer() which allows you to clear the buffer.
@mwadams mwadams linked an issue Jul 7, 2025 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Jul 7, 2025

Test Results

  1 files  ± 0    1 suites  ±0   0s ⏱️ ±0s
221 tests  - 12  221 ✅  - 12  0 💤 ±0  0 ❌ ±0 
222 runs   - 14  222 ✅  - 14  0 💤 ±0  0 ❌ ±0 

Results for commit 7c93001. ± Comparison against base commit 506f706.

♻️ This comment has been updated with latest results.

@mwadams mwadams requested review from Copilot and idg10 July 7, 2025 11:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an overload to ReturnRentedBuffer that accepts a clearBuffer flag and updates calls (including in Dispose) to optionally clear the buffer when returning it to the pool.

  • Introduce ReturnRentedBuffer(char[]? buffer, bool clearBuffer)
  • Update existing no-arg overload to call new overload with clearBuffer = false
  • Change Dispose to return buffer with clearBuffer = true
Comments suppressed due to low confidence (2)

Solutions/Corvus.HighPerformance/Corvus.HighPerformance/ValueStringBuilder.cs:92

  • The XML doc for the clearBuffer parameter is missing a closing tag and uses <para> instead of <param>. Change to <param name="clearBuffer">If true, the buffer will be cleared before returning.</param>.
    /// <para name="clearBuffer">If <see langword="true"/> then clear the buffer when returned.

Solutions/Corvus.HighPerformance/Corvus.HighPerformance/ValueStringBuilder.cs:93

  • [nitpick] Consider adding unit tests for the new overload to verify that clearBuffer correctly clears data when the flag is true, and leaves it intact when false.
    public static void ReturnRentedBuffer(char[]? buffer, bool clearBuffer)

@github-actions
Copy link

github-actions bot commented Jul 7, 2025

Code Coverage Summary Report - Linux (net8.0)

Summary
Generated on: 07/07/2025 - 12:31:08
Parser: Cobertura
Assemblies: 2
Classes: 15
Files: 13
Line coverage: 81.4% (399 of 490)
Covered lines: 399
Uncovered lines: 91
Coverable lines: 490
Total lines: 1419
Branch coverage: 63.7% (65 of 102)
Covered branches: 65
Total branches: 102
Method coverage: Feature is only available for sponsors

Coverage

Corvus.HighPerformance - 65.7%
Name Line Branch
Corvus.HighPerformance 65.7% 60.2%
Corvus.HighPerformance.ValueStringBuilder 65.7% 60.2%
Corvus.HighPerformance.Specs - 94.7%
Name Line Branch
Corvus.HighPerformance.Specs 94.7% 75%
Corvus.HighPerformance.Specs.ExceptionStepDefinitions 45.4% 50%
Reqnroll_GeneratedTests_MSTestAssemblyHooks 80%
ValueStringBuilderFeatures.AppendContentIntoAValueStringBuilderFeature 100%
ValueStringBuilderFeatures.Net80.AppendCompositeFormatIntoAValueStringBuild
erFeature
100%
ValueStringBuilderFeatures.ReplaceContentInAValueStringBuilderFeature 100%
ValueStringBuilderFeatures.RetrieveAMemoryFromAValueStringBuilderFeature 100%
ValueStringBuilderFeatures.RetrieveASpanFromAValueStringBuilderFeature 100%
ValueStringBuilderFeatures.ValueStringBuilderStepDefinitions 100% 50%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver 92.4% 80%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.AppendFormatOperati
on
100%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.AppendInt32Operatio
n
100%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.AppendOperation 100%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.AttemptReplaceOpera
tion
91.6%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.ReplaceOperation 100%

@github-actions
Copy link

github-actions bot commented Jul 7, 2025

Code Coverage Summary Report - Windows (net8.0)

Summary
Generated on: 7/7/2025 - 12:33:28 PM
Parser: Cobertura
Assemblies: 2
Classes: 15
Files: 13
Line coverage: 81.4% (399 of 490)
Covered lines: 399
Uncovered lines: 91
Coverable lines: 490
Total lines: 1506
Branch coverage: 63.7% (65 of 102)
Covered branches: 65
Total branches: 102
Method coverage: Feature is only available for sponsors

Coverage

Corvus.HighPerformance - 65.7%
Name Line Branch
Corvus.HighPerformance 65.7% 60.2%
Corvus.HighPerformance.ValueStringBuilder 65.7% 60.2%
Corvus.HighPerformance.Specs - 94.7%
Name Line Branch
Corvus.HighPerformance.Specs 94.7% 75%
Corvus.HighPerformance.Specs.ExceptionStepDefinitions 45.4% 50%
Reqnroll_GeneratedTests_MSTestAssemblyHooks 80%
ValueStringBuilderFeatures.AppendContentIntoAValueStringBuilderFeature 100%
ValueStringBuilderFeatures.Net80.AppendCompositeFormatIntoAValueStringBuild
erFeature
100%
ValueStringBuilderFeatures.ReplaceContentInAValueStringBuilderFeature 100%
ValueStringBuilderFeatures.RetrieveAMemoryFromAValueStringBuilderFeature 100%
ValueStringBuilderFeatures.RetrieveASpanFromAValueStringBuilderFeature 100%
ValueStringBuilderFeatures.ValueStringBuilderStepDefinitions 100% 50%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver 92.4% 80%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.AppendFormatOperati
on
100%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.AppendInt32Operatio
n
100%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.AppendOperation 100%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.AttemptReplaceOpera
tion
91.6%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.ReplaceOperation 100%

@github-actions
Copy link

github-actions bot commented Jul 7, 2025

Code Coverage Summary Report - Windows (net481)

Summary
Generated on: 7/7/2025 - 12:33:32 PM
Parser: Cobertura
Assemblies: 2
Classes: 13
Files: 10
Line coverage: 80.9% (390 of 482)
Covered lines: 390
Uncovered lines: 92
Coverable lines: 482
Total lines: 1398
Branch coverage: 64.8% (70 of 108)
Covered branches: 70
Total branches: 108
Method coverage: Feature is only available for sponsors

Coverage

Corvus.HighPerformance - 66.5%
Name Line Branch
Corvus.HighPerformance 66.5% 61.9%
Corvus.HighPerformance.ValueStringBuilder 66.5% 61.9%
Corvus.HighPerformance.Specs - 94.3%
Name Line Branch
Corvus.HighPerformance.Specs 94.3% 75%
Corvus.HighPerformance.Specs.ExceptionStepDefinitions 45.4% 50%
Reqnroll_GeneratedTests_MSTestAssemblyHooks 80%
ValueStringBuilderFeatures.AppendContentIntoAValueStringBuilderFeature 100%
ValueStringBuilderFeatures.ReplaceContentInAValueStringBuilderFeature 100%
ValueStringBuilderFeatures.RetrieveAMemoryFromAValueStringBuilderFeature 100%
ValueStringBuilderFeatures.RetrieveASpanFromAValueStringBuilderFeature 100%
ValueStringBuilderFeatures.ValueStringBuilderStepDefinitions 100% 50%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver 92% 80%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.AppendInt32Operatio
n
100%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.AppendOperation 100%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.AttemptReplaceOpera
tion
91.6%
ValueStringBuilderFeatures.ValueStringBuilderTestDriver.ReplaceOperation 100%

@mwadams mwadams merged commit f1ff50a into main Jul 7, 2025
8 checks passed
@mwadams mwadams deleted the feature/11-valuestringbuilder-buffer-clearing branch July 7, 2025 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ValueStringBuilder buffer clearing

3 participants