From: Philippe Canal Date: Wed, 21 Jan 2015 18:03:29 +0000 (-0600) Subject: Schedules the I/O as soon as possible (i.e. after all sources have been read) X-Git-Url: https://root.cern.ch/gitweb?p=root.git;a=commitdiff_plain;h=b1f38511e1e9bccb595c1d798c1c39624934eb3c Schedules the I/O as soon as possible (i.e. after all sources have been read) One significant consequence is that now when an object is stored in a split branch the rule is associtated with the branch of the last of the rule's sources rather than the last of the object's data member. This fixes: ROOT-7009 Conflicts: io/io/src/TStreamerInfo.cxx --- diff --git a/io/io/src/TStreamerInfo.cxx b/io/io/src/TStreamerInfo.cxx index 7c02c59..4f26764 100644 --- a/io/io/src/TStreamerInfo.cxx +++ b/io/io/src/TStreamerInfo.cxx @@ -89,6 +89,20 @@ static void R__TObjArray_InsertAt(TObjArray *arr, TObject *obj, Int_t at) arr->AddAt( obj, at); } +static void R__TObjArray_InsertAt(TObjArray *arr, std::vector &objs, Int_t at) +{ + // Slide by enough. + Int_t offset = objs.size(); + Int_t last = arr->GetLast(); + arr->AddAtAndExpand(arr->At(last),last+offset); + for(Int_t ind = last-1; ind >= at; --ind) { + arr->AddAt( arr->At(ind), ind+offset); + }; + for(size_t ins = 0; ins < objs.size(); ++ins) { + arr->AddAt(objs[ins], at+ins); + } +} + static void R__TObjArray_InsertAfter(TObjArray *arr, TObject *newobj, TObject *oldobj) { // Slide by one. @@ -4198,6 +4212,7 @@ void TStreamerInfo::InsertArtificialElements(const TObjArray *rules) break; } } + // NOTE: Before adding the rule we should check that the source do // existing in this StreamerInfo. const TObjArray *sources = rule->GetSource(); @@ -4224,6 +4239,9 @@ void TStreamerInfo::InsertArtificialElements(const TObjArray *rules) if (!rule) continue; TStreamerArtificial *newel; + typedef std::vector vec_t; + vec_t toAdd; + if (rule->GetTarget()==0) { TString newName; newName.Form("%s_rule%d",fClass->GetName(),count); @@ -4234,8 +4252,9 @@ void TStreamerInfo::InsertArtificialElements(const TObjArray *rules) newel->SetBit(TStreamerElement::kWholeObject); newel->SetReadFunc( rule->GetReadFunctionPointer() ); newel->SetReadRawFunc( rule->GetReadRawFunctionPointer() ); - fElements->Add(newel); + toAdd.push_back(newel); } else { + toAdd.reserve(rule->GetTarget()->GetEntries()); TObjString * objstr = (TObjString*)(rule->GetTarget()->At(0)); if (objstr) { TString newName = objstr->String(); @@ -4246,7 +4265,7 @@ void TStreamerInfo::InsertArtificialElements(const TObjArray *rules) fClass->GetDataMember( newName )->GetTypeName()); newel->SetReadFunc( rule->GetReadFunctionPointer() ); newel->SetReadRawFunc( rule->GetReadRawFunctionPointer() ); - fElements->Add(newel); + toAdd.push_back(newel); } else { // This would be a completely new member (so it would need to be cached) // TOBEDONE @@ -4260,12 +4279,31 @@ void TStreamerInfo::InsertArtificialElements(const TObjArray *rules) fClass->GetDataMemberOffset(newName), TStreamerInfo::kArtificial, fClass->GetDataMember( newName )->GetTypeName()); - fElements->Add(newel); + toAdd.push_back(newel); } } } } // For each target of the rule } + // Now find we with need to add them + TIter s_iter(rule->GetSource()); + Int_t loc = -1; + while( TObjString *s = (TObjString*)s_iter() ) { + for(Int_t i = fElements->GetLast(); i >= 0 && (i+1) >= loc; --i) { + if (s->String() == fElements->UncheckedAt(i)->GetName()) { + if (loc == -1 || (i+1)>loc) { + loc = i+1; + } + } + } + } + if (loc == -1) { + for(vec_t::iterator iter = toAdd.begin(); iter != toAdd.end(); ++iter) { + fElements->Add(*iter); + } + } else { + R__TObjArray_InsertAt(fElements, toAdd, loc); + } } // None of the target of the rule are on file. }