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

InMemDicomObject Length::UNDEFINED after modify #364

Merged
merged 6 commits into from
Jun 14, 2023

Conversation

jmlaka
Copy link
Contributor

@jmlaka jmlaka commented Jun 11, 2023

As an InMemDicomObject can have a certain defined Length after parsing dicom data,
it is necessary to reset or recalculate this Length after calling any methods that modify
the object's inner entries value e.g. .put() .remove_element() ...

The Length is set to Length::UNDEFINED as recalculating it might be expensive.

- Length::UNDEFINED after modification
- to it's inner entries value
Copy link
Owner

@Enet4 Enet4 left a comment

Choose a reason for hiding this comment

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

Thank you for working on this.

Could you adjust some of these methods so that the length is not reset when no changes were truly made? Not that it's a huge problem, but it feels surprising for a method representing an operation as simple as removing an attribute to return an error and still make changes to the underlying object. I left some examples, it should not be hard to do the same for the other methods.

object/src/mem.rs Outdated Show resolved Hide resolved
object/src/mem.rs Outdated Show resolved Hide resolved
@jmlaka
Copy link
Contributor Author

jmlaka commented Jun 12, 2023 via email

@jmlaka
Copy link
Contributor Author

jmlaka commented Jun 13, 2023

I just removed some duplicate code.

The methods you mentioned did not need changes, as they internally call self.put() - which is already handled.

@jmlaka
Copy link
Contributor Author

jmlaka commented Jun 13, 2023

Still wrong :) Will be back

Copy link
Owner

@Enet4 Enet4 left a comment

Choose a reason for hiding this comment

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

Great! Only one minor concern left.

object/src/mem.rs Show resolved Hide resolved
Co-authored-by: Eduardo Pinho <enet4mikeenet@gmail.com>
Copy link
Owner

@Enet4 Enet4 left a comment

Choose a reason for hiding this comment

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

The test failed. Please see the suggestion inline for a possible solution.

object/src/mem.rs Outdated Show resolved Hide resolved
Copy link
Owner

@Enet4 Enet4 left a comment

Choose a reason for hiding this comment

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

Awesome! Thank you again, @jmlaka!

@Enet4 Enet4 merged commit ca66e6a into Enet4:master Jun 14, 2023
4 checks passed
@jmlaka jmlaka deleted the reset_InMemObject_Length branch June 14, 2023 18:11
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.

None yet

2 participants