KEMBAR78
[Performance] XmlSerializationWriter.WriteTypedPrimitive is converting primitive types to string before writing them to the XmlWriter · Issue #76434 · dotnet/runtime · GitHub
Skip to content

[Performance] XmlSerializationWriter.WriteTypedPrimitive is converting primitive types to string before writing them to the XmlWriter #76434

@TrayanZapryanov

Description

@TrayanZapryanov

Description

Possible optimization found.
Current implementation of writing primitive types fallbacks to string using XmlConvert.ToString(..).

protected void WriteTypedPrimitive(string? name, string? ns, object o, bool xsiType)

Regression?

No

Analysis

How to optimize:
Write to char[] and then use XmlWriter.WriteChars(...). This should eliminate all temporary string for int/DateTime/guid.... types, which should be majority when serializing custom types. This change will help us later to use XmlSerializationWriter.WriteTypedPrimitive method in XmlSerializationWriterILGen instead of again creating strings and using XmlConvert.ToString(...)

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions