@@ -1289,33 +1289,12 @@ Cppyy::TCppIndex_t Cppyy::GetNumBases(TCppScope_t klass)
1289
1289
// / calling this function on an instance of `C` will return 3, the steps
1290
1290
// / required to go from C to X.
1291
1291
Cppyy::TCppIndex_t Cppyy::GetNumBasesLongestBranch (TCppScope_t klass) {
1292
- std::vector<TCppScope_t> directbases ;
1292
+ std::vector<size_t > num ;
1293
1293
for (TCppIndex_t ibase = 0 ; ibase < GetNumBases (klass); ++ibase)
1294
- directbases.push_back (GetScope (GetBaseName (klass, ibase)));
1295
- return directbases.size ();
1296
- // if (directbases.empty()) {
1297
- // // This is a leaf with no bases
1298
- // return 0;
1299
- // }
1300
-
1301
- // else {
1302
- // // If there is at least one direct base
1303
- // std::vector<Cppyy::TCppIndex_t> nbases_branches;
1304
- // nbases_branches.reserve(ndirectbases);
1305
- // // Traverse all direct bases of the current class and call the function
1306
- // // recursively
1307
- // for (auto baseclass : TRangeDynCast<TBaseClass>(directbases)) {
1308
- // if (!baseclass)
1309
- // continue;
1310
- // if (auto baseclass_tclass = baseclass->GetClassPointer()) {
1311
- // nbases_branches.emplace_back(GetLongestInheritancePath(baseclass_tclass));
1312
- // }
1313
- // }
1314
- // // Get longest path among the direct bases of the current class
1315
- // auto longestbranch = std::max_element(std::begin(nbases_branches), std::end(nbases_branches));
1316
- // // Add 1 to include the current class in the count
1317
- // return 1 + *longestbranch;
1318
- // }
1294
+ num.push_back (GetNumBasesLongestBranch (Cppyy::GetBaseScope (klass, ibase)));
1295
+ if (num.empty ())
1296
+ return 0 ;
1297
+ return *std::max_element (num.begin (), num.end ()) + 1 ;
1319
1298
}
1320
1299
1321
1300
std::string Cppyy::GetBaseName (TCppType_t klass, TCppIndex_t ibase)
0 commit comments