Skip to content

Use StringBuilder.GetChunks in MySqlParameter.AppendBinary #977

@bgrainger

Description

@bgrainger

If MySqlParameter.Value is set to a StringBuilder instance (#975) and MySqlCommand.Prepare() is called, the code currently calls StringBuilder.ToString() and writes it as a length-encoded UTF-8 string.

In .NET 5.0, it should be more performant to use GetChunks:

  1. loop over the chunks and sum the results of GetByteCount (for a UTF8Encoder) calculate the total length of the UTF-8 string
  2. write the length prefix
  3. loop over the chunks and write each out (encoding each one into UTF-8)

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions