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

Specify an initial capacity when creating the property lists by Numpsy · Pull Request #423 · openmcdf/openmcdf · GitHub

Specify an initial capacity when creating the property lists - #423

Merged
jeremy-visionaid merged 1 commit into
openmcdf:mainfrom
Numpsy:reserve_space
Apr 30, 2026
Merged

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

Conversation

Numpsy commented Apr 27, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Given that we know how many properties there are, we can specify the inital capacity so that the lists don't have to grow when properties are added during the file load.

Just a thought when testing things - it saves a few allocations by not having to resize the lists when populating them

Before

| Method                                   | Mean     | Error     | StdDev    | Gen0   | Allocated |
|----------------------------------------- |---------:|----------:|----------:|-------:|----------:|
| ReadSummaryInformation                   | 2.647 us | 0.2255 us | 0.0124 us | 0.1678 |   2.79 KB |
| ReadDocumentSummaryInformation           | 5.696 us | 2.8983 us | 0.1589 us | 0.2899 |    4.8 KB |
| ReadWinUnicodeDocumentSummaryInformation | 4.634 us | 0.4385 us | 0.0240 us | 0.3510 |   5.73 KB |

After:

| Method                                   | Mean     | Error     | StdDev    | Gen0   | Allocated |
|----------------------------------------- |---------:|----------:|----------:|-------:|----------:|
| ReadSummaryInformation                   | 2.579 us | 0.3110 us | 0.0170 us | 0.1564 |   2.62 KB |
| ReadDocumentSummaryInformation           | 5.533 us | 0.2134 us | 0.0117 us | 0.2747 |    4.6 KB |
| ReadWinUnicodeDocumentSummaryInformation | 4.542 us | 0.1433 us | 0.0079 us | 0.3281 |   5.47 KB |

Any thoughts?

Comment thread OpenMcdf.Ole/ListExtensions.cs Outdated
Numpsy changed the title Reserve space in the property lists before adding items Specify an initial capacity when creating the property lists Apr 28, 2026

Numpsy commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Given that the collections are populated in the class constructors, I had a go at just constructing the lists with the required capacity rather than resizing them after creation.

Comment thread OpenMcdf.Ole/OlePropertiesContainer.cs Outdated
Given that we know how many properties there are, we can reserve the required amount of space so that the lists don't have to grow when properties are added during the file load. This saves a few allocations.
Numpsy marked this pull request as ready for review April 29, 2026 21:10
}

// Build the User Defined properties container, if the property set is present.
if (pStream.NumPropertySets == 2)

Numpsy Apr 29, 2026
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

On a related note (not part of this change, something that could be a separate issue) - the PropertySetStream documentation states

The current logic always reads the second property set if present, but it could validate this requirement (same on writing - making sure it doesn't write the UserDefinedProperties set for any parent other than DocSummaryInformation may or may not be something that could be controlled by a strict validation flag

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