Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2534 Improve performance of Date handling #2541

Merged
merged 5 commits into from
Jul 19, 2023

Conversation

ewoutkramer
Copy link
Member

@ewoutkramer ewoutkramer commented Jul 18, 2023

Replicated changes from DateTime to Date.

Resolves #2534.

Copy link
Member

@marcovisserFurore marcovisserFurore left a comment

Choose a reason for hiding this comment

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

See my remarks..

src/Hl7.Fhir.Base/Model/Date.cs Outdated Show resolved Hide resolved
src/Hl7.Fhir.Support.Poco.Tests/Model/DateTests.cs Outdated Show resolved Hide resolved
src/Hl7.FhirPath.Tests/Tests/BasicFunctionTests.cs Outdated Show resolved Hide resolved
@marcovisserFurore marcovisserFurore merged commit 286cf55 into develop Jul 19, 2023
13 checks passed
@marcovisserFurore marcovisserFurore deleted the feature/2534-improve-date-performance branch July 19, 2023 14:04
[NonSerialized] // To prevent binary serialization from serializing this field
private P.Date? _parsedValue = null;

private static readonly P.Date INVALID_VALUE = P.Date.Today();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would resolve to the current value on initialization of the app, hence long running services would have the boot time in this value, shouldn't it be a function so it is evaluated each time it is called?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. hasInvalidParsedValue() uses ReferenceEquals() to compare the cached time to INVALID_VALUE, so the actual value does not matter: it could have been mine or your birthdate as well. It's used here as a sentinel value to just indicate the value is invalid (as opposed to not cached (null)). It avoids keeping a separate bool hasInvalidValue that I need to keep synchronized.

Copy link
Contributor

Choose a reason for hiding this comment

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

In case someone is looking at the data, would it be better to use something like DateTime.MinValue to make it obvious?

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.

Improve performance of Poco Date
4 participants