Skip to content

Fix Insert capacity calculation for existing large buffers - #150

Open
dajiaohuang wants to merge 1 commit into
Cysharp:masterfrom
dajiaohuang:fix/zstring-insert-capacity-20261015
Open

dajiaohuang wants to merge 1 commit into
Cysharp:masterfrom
dajiaohuang:fix/zstring-insert-capacity-20261015

Conversation

@dajiaohuang

Copy link
Copy Markdown

Problem

A supported Utf16ValueStringBuilder.Insert can throw ArgumentException: Destination is too short when existing text exceeds the default buffer size. For example, append 33,000 a characters, then call Insert(1, "b"). The new buffer is sized using the insertion index rather than the existing text length, so it cannot hold the retained suffix.

Related: #125 (closed by stale automation).

Change

Size the new buffer from the current length plus the inserted text length. Add BCL-comparison regressions for pooled/thread-static builders and insertion at the start/middle. Update the Unity source through the existing netstandard2.1 post-build copy target.

Validation

  • All 4 new cases fail at master b9c1d8a and pass with this change.
  • Release solution build passes (existing warnings remain).
  • Full maintained test project: 151 passed, using DOTNET_ROLL_FORWARD=Major because .NET 7 runtime is unavailable locally.
  • No Unity editor/TMP/IL2CPP execution; no allocation or performance claims.

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.

1 participant