GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — perf: drop redundant char* fixed in MessagePackWriter.Write(string) by unsafePtr · Pull Request #2258 · MessagePack-CSharp/MessagePack-CSharp

Conversation

@unsafePtr

@unsafePtr unsafePtr commented May 4, 2026

Copy link
Copy Markdown
Contributor

On SPAN_BUILTIN targets (netstandard2.1/net8.0/net9.0), use the span-based Encoding.GetBytes(ReadOnlySpan<char>, Span<byte>) overload so the fixed (char* pValue = value) pin can go away. The Encoding API pins the source itself for the duration of the encode, which is shorter than holding the pin across WriteString_PostEncoding.

Legacy targets (netstandard2.0/net472) keep the original fixed (char* …) path under #else.

The fixed (byte* pBuffer = &buffer) stays for now — WriteString_PostEncoding still takes byte* and uses Buffer.MemoryCopy for the overlapping prefix shift. Dropping that pin too would mean rewriting WriteString_PostEncoding to ref byte + MemoryMarshal.CreateSpan(...).CopyTo(...), but MemoryMarshal.CreateSpan is netstandard2.1+ only (not in the System.Memory backport for netstandard2.0/net472), so that's a bigger refactor for another PR.

Test plan

  • Builds clean on all 5 TFMs (netstandard2.0;netstandard2.1;net8.0;net9.0;net472)
  • MessagePack.Tests — 999/999 pass on net9.0, 968/968 on net472

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@unsafePtr
perf: drop redundant char* fixed in MessagePackWriter.Write(string)
20a17a8
@unsafePtr

unsafePtr commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

@AArnott do I need to add any specific tests? Thought this change is straightforward

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI mentioned this pull request Jul 8, 2026
Port span-based Encoding.GetBytes to Write(string) and Write(ReadOnlySpan<char>) AArnott/Nerdbank.MessagePack#1004
Merged
AArnott
AArnott requested changes Jul 8, 2026
View reviewed changes
Comment thread src/MessagePack/MessagePackWriter.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/MessagePack/MessagePackWriter.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

unsafePtr and others added 2 commits July 8, 2026 16:15
@unsafePtr @AArnott
Update src/MessagePack/MessagePackWriter.cs
2007d22
Co-authored-by: Andrew Arnott <[email protected]>
@unsafePtr @AArnott
Update src/MessagePack/MessagePackWriter.cs
cfbb573
Co-authored-by: Andrew Arnott <[email protected]>
@unsafePtr
unsafePtr requested a review from AArnott July 8, 2026 13:15
AArnott
AArnott approved these changes Jul 8, 2026
View reviewed changes
AArnott
AArnott approved these changes Jul 8, 2026
View reviewed changes
@AArnott
AArnott merged commit 781513b into MessagePack-CSharp:master Jul 8, 2026
3 checks passed

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Sep 18, 2026
Bump MessagePack from 2.5.301 to 3.1.9 SadPossum/GMA-Skeleton#42
Closed
deps: Bump MessagePack from 3.1.8 to 3.1.9 Jaxelr/Carter.Cache#410
Closed
Bump the other group with 4 updates TheSevenPens/OpenTabletArtist#749
Closed
Bump the rpc group with 2 updates TheSevenPens/OpenTabletArtist#755
Closed
Bump MessagePack from 3.1.7 to 3.1.9 rogerbriggen/aspire_otel_test#97
Open
Bump MessagePack from 3.1.7 to 3.1.9 LLM-Dev-Studio/ai-dev#101
Closed
Bump the nuget group with 10 updates dotnet/docs#56226
Merged
This was referenced Sep 26, 2026
Bump MessagePack from 2.5.301 to 3.1.10 neo-project/neo-express#867
Closed
Bump MessagePack from 3.1.7 to 3.1.10 LLM-Dev-Studio/ai-dev#104
Closed
build(deps): Bump MessagePack from 2.5.301 to 3.1.10 NewVixSmart/NewVix_ERP#13
Closed
Bump MessagePack from 2.5.302 to 3.1.10 feiwche/finara#20
Open
chore(deps): Bump MessagePack from 2.5.302 to 3.1.9 Tibirot/FieldKit#348
Closed
Bump MessagePack from 2.5.302 to 3.1.10 BurkeStrang/blog#111
Closed
Bump coverlet.collector and 26 others mpaulosky/IssueTracker#128
Closed
Bump MessagePack from 2.5.302 to 3.1.10 CommunityToolkit/Aspire#2132
Closed
Bump MessagePack from 2.5.302 to 3.1.10 afnan/allspice-clean-modular-monolith-template#77
Open
Bump the nuget group with 23 updates SapiensAnatis/Dawnshard#1541
Merged
Bump MessagePack from 3.1.7 to 3.1.10 Blooym/Dalamud.GoodFriend#248
Open
This was referenced Oct 4, 2026
Bump MessagePack from 3.1.7 to 3.1.11 LLM-Dev-Studio/ai-dev#105
Open
⬆️ .NET: Bump MessagePack from 2.5.302 to 3.1.11 jdeleonferreira/smart-timetable-generator#22
Open
This was referenced Nov 13, 2026
Bump the nuget group with 17 updates NikiforovAll/adaptive-rate-limiting-dotnet#16
Closed
Bump the nuget group with 1 update rian-be/FiveM.Nui#11
Merged
Bump the nuget group with 1 update TanmayS0406/SSMSClaude-Script#14
Closed
deps: Bump MessagePack from 2.5.307 to 3.1.12 RMBarros-Dev/Hydra-Digital-Shop#14
Closed
deps: Bump Aspire.Hosting.Redis and MessagePack RMBarros-Dev/Hydra-Digital-Shop#12
Merged
Bump Avalonia and 11 others jeremychn/amarre#8
Closed
Bump the dotnet-major group with 8 updates chelomama-dev/finances-hub#32
Open
deps: Bump MessagePack from 2.5.307 to 3.1.12 erikdarlingdata/PerformanceStudio#715
Closed
Bump AWSSDK.S3 and 16 others PauloVianaR/ViverAppWeb#27
Closed
Bump the dotnet-dependencies group with 17 updates PauloVianaR/ViverAppWeb#28
Open
Bump MessagePack from 2.5.307 to 3.1.12 afernandes/DiscoveryDeviceAndroid#5
Open
Bump MessagePack from 2.5.307 to 3.1.12 ErikEJ/SqlServer.Rules#820
Closed
Bump MessagePack from 2.5.307 to 3.1.12 thekim1/kalla#837
Closed
Bump the nuget-major group with 9 updates Tjeerd-menno/nats-manager-ui#386
Closed
Bump MessagePack from 2.5.307 to 3.1.12 jonnymuir/Heliograph#34
Closed
Bump AWSSDK.S3 and 15 others PauloVianaR/ViverAppWeb#30
Open
Bump the nuget group with 5 updates Ki-Will/server#3
Open
Bump the nuget-shipped group with 2 updates alexFinn97/scaffolder-for-optimizely#8
Closed
This was referenced Nov 20, 2026
Bump the nuget group with 17 updates NikiforovAll/adaptive-rate-limiting-dotnet#17
Closed
Bump MessagePack from 3.1.7 to 3.1.9 IntelliTect/IntelliTect.AspNetCore.SignalR.SqlServer#26
Closed
Bump MessagePack from 2.5.307 to 3.1.12 Tjeerd-menno/nats-manager-ui#398
Merged
Bump the nuget group with 3 updates TanmayS0406/SSMSClaude-Script#17
Open
Bump MessagePack and 7 others chelomama-dev/finances-hub#34
Open
Bump AWSSDK.S3 and 15 others PauloVianaR/ViverAppWeb#32
Closed
Bump the dotnet-dependencies group with 16 updates PauloVianaR/ViverAppWeb#33
Open
Bump MessagePack from 2.5.303 to 3.1.12 mortenbrudvik/Obfy#43
Closed
deps: Bump the "weekly" group with 1 update across multiple ecosystems ftichy/MiniShop#192
Merged
Bump MessagePack from 2.5.303 to 3.1.12 D-WIS/DWIS-Blackboard-Tests#45
Open
Bump the nuget group with 17 updates NikiforovAll/adaptive-rate-limiting-dotnet#18
Open
@dependabot dependabot Bot mentioned this pull request Nov 28, 2026
Bump the nuget group with 1 update EIHRTeam/EndfieldStudio#11
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AArnott AArnott AArnott approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@unsafePtr @AArnott
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.