FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Improve DictionaryProperty.Read/Write encoding by Numpsy · Pull Request #421 · openmcdf/openmcdf · GitHub

Improve DictionaryProperty.Read/Write encoding - #421

Merged
jeremy-visionaid merged 1 commit into
openmcdf:mainfrom
Numpsy:cahe_encoding
Apr 22, 2026
Merged

jeremy-visionaid merged 1 commit into
openmcdf:mainfrom
Numpsy:cahe_encoding

Conversation

Numpsy commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

…once

Instead of once per property.
As there are multiple properties, and all have the same code page, we can call Encoding.GetEncoding once and use it for all the properties, rather than calling GetEncoding per property.

This actually gives a measurable performance increase when reading DocumentSummaryInformation property streams with UserDefined properties.

This was an observation whilst doing #420 that I noticed when I changed a Unicode case to always use Encoding.Unicode instead of calling Encoding.GetEncoding and it got faster (GetEncoding appears to do some internal locking that we can skip by only doing it once, at least when all the additional code pages have been registered in PropertyFactory)

I currently get these benchmark results with the main branch:

| Method                                   | Mean     | Error     | StdDev    | Gen0   | Allocated |
|----------------------------------------- |---------:|----------:|----------:|-------:|----------:|
| ReadSummaryInformation                   | 2.745 us | 0.2486 us | 0.0136 us | 0.1869 |   3.07 KB |
| ReadDocumentSummaryInformation           | 6.101 us | 0.0717 us | 0.0039 us | 0.3204 |   5.26 KB |
| ReadWinUnicodeDocumentSummaryInformation | 6.568 us | 0.3831 us | 0.0210 us | 0.3891 |   6.43 KB |

But after this change I get

| Method                                   | Mean     | Error     | StdDev    | Gen0   | Allocated |
|----------------------------------------- |---------:|----------:|----------:|-------:|----------:|
| ReadSummaryInformation                   | 2.729 us | 0.2317 us | 0.0127 us | 0.1869 |   3.07 KB |
| ReadDocumentSummaryInformation           | 5.608 us | 0.4978 us | 0.0273 us | 0.3128 |    5.2 KB |
| ReadWinUnicodeDocumentSummaryInformation | 4.630 us | 0.5672 us | 0.0311 us | 0.3738 |   6.18 KB |

The Unicode case gets a bigger difference because the test file contains more properties.
Seems worth doing though when it's quite simple.

…once

Instead of once per property.
As there are multiple properties, and all have the same code page, we can call Encoding.GetEncoding once and use it for all the properties, rather than calling GetEncoding per property.

This actually gives a measurable performance increase when reading DocumentSummaryInformation property streams with UserDefined properties.

Numpsy commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

We could probably do something similar with the reading of LPSTR properties, but that's not so self contained so that's just a future thought.

jeremy-visionaid changed the title Change DictionaryProperty.Read/Write to only get the string encoding … Improve DictionaryProperty.Read/Write encoding Apr 22, 2026
jeremy-visionaid merged commit 5a7681b into openmcdf:main Apr 22, 2026
2 checks passed
Numpsy deleted the cahe_encoding branch April 23, 2026 18:48
This was referenced May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL