-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[core] Make TDirectory::Append tolerant to identical objects. #20888
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| if (replace && obj->GetName() && obj->GetName()[0]) { | ||
| TObject *old; | ||
| while (nullptr != (old = GetList()->FindObject(obj->GetName()))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The while loop implies that the list could contains multiple times the same names when this is called. In this case the net result was to remove all duplicates and add only the one passed.
With the new code it seems that if the list contains multiple time the same name and already contains the item being passed we can have:
- before this PR: list contains only the argument
- after this PR: list contains the argument and possibly many duplicates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this should be addressed now!
pcanal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment.
Test Results 23 files 23 suites 3d 18h 29m 37s ⏱️ Results for commit 359e187. |
359e187 to
aa1d14c
Compare
When calling TDirectory::Append(obj, replace=true), and obj is already in the directory, don't issue a warning. Proceed to clear the list of any duplicates, issuing a warning for each. This will enable workflows such as: auto h = new TH1D(...); directory->Append(h, true); After this change, the above lines work both with implicit object ownership off and on.
aa1d14c to
0728d2c
Compare
When calling TDirectory::Append(obj, replace=true), and obj is already in the directory, return without doing anything.
If obj has the same name as an existing object, but is physically different, the usual warning is raised.
This will enable workflows such as:
After this change, the above lines work both with and without auto registration to gDirectory. This is needed to prepare ROOT for working without auto registration.