Commit ab5324d
avoid Lock acquisition on ErrorCount/WarningCount when no errors exist (dotnet#4157)
* avoid Lock acquisition on ErrorCount/WarningCount when no errors exist
1. _hasErrorOrWarning marked volatile (line 278) -- the field was already read without a lock at line 1212, so this makes the existing pattern and the new fast paths correct across all memory models.
2. ErrorCount fast path -- returns 0 immediately when _hasErrorOrWarning is false, skipping the lock. Safe because _hasErrorOrWarning is only set to false under the lock when _errors is also nulled.
3. WarningCount fast path -- same treatment.
* Update src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update TdsParserStateObject.cs
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent bf9c17d commit ab5324d
1 file changed
Lines changed: 11 additions & 1 deletion
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| |||
2672 | 2672 | | |
2673 | 2673 | | |
2674 | 2674 | | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
2675 | 2681 | | |
2676 | 2682 | | |
2677 | 2683 | | |
| |||
2713 | 2719 | | |
2714 | 2720 | | |
2715 | 2721 | | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
2716 | 2726 | | |
2717 | 2727 | | |
2718 | 2728 | | |
| |||
0 commit comments