diff --git a/tree/dataframe/inc/ROOT/RDF/RDisplay.hxx b/tree/dataframe/inc/ROOT/RDF/RDisplay.hxx index d7b1de7c2f19f5f38135e55d10d6c077c66686a4..c1b0848406c3cc762954adad0daab356dd601e0d 100644 --- a/tree/dataframe/inc/ROOT/RDF/RDisplay.hxx +++ b/tree/dataframe/inc/ROOT/RDF/RDisplay.hxx @@ -183,6 +183,8 @@ private: /// If the number of required rows has been parsed, returns false. bool HasNext() { return fEntries > 0; } + void EnsureCurrentColumnWidth(size_t w); + public: //////////////////////////////////////////////////////////////////////////// /// Creates an RDisplay to print the event values diff --git a/tree/dataframe/src/RDFDisplay.cxx b/tree/dataframe/src/RDFDisplay.cxx index d554a361198e96571c73eb55b8126a9d478ebf38..679c59cb5b38d29ac7c4962d14522e84fc85d940 100644 --- a/tree/dataframe/src/RDFDisplay.cxx +++ b/tree/dataframe/src/RDFDisplay.cxx @@ -2,6 +2,7 @@ #include "TInterpreter.h" #include <iomanip> +#include <limits> namespace ROOT { namespace Internal { @@ -89,12 +90,23 @@ bool RDisplayElement::IsEmpty() const } // namespace Internal namespace RDF { -void RDisplay::AddToRow(const std::string &stringEle) + +void RDisplay::EnsureCurrentColumnWidth(size_t w) { // If the current element is wider than the widest element found, update the width - if (fWidths[fCurrentColumn] < stringEle.length()) { - fWidths[fCurrentColumn] = stringEle.length(); + if (fWidths[fCurrentColumn] < w) { + if (w > std::numeric_limits<unsigned short>::max()) { + w = std::numeric_limits<unsigned short>::max(); + } + fWidths[fCurrentColumn] = (unsigned short) w; } +} + +void RDisplay::AddToRow(const std::string &stringEle) +{ + // If the current element is wider than the widest element found, update the width + EnsureCurrentColumnWidth(stringEle.length()); + // Save the element... fTable[fCurrentRow][fCurrentColumn] = DElement_t(stringEle); @@ -113,18 +125,14 @@ void RDisplay::AddCollectionToRow(const std::vector<std::string> &collection) auto element = DElement_t(stringEle); // Update the width if this element is the biggest found - if (fWidths[fCurrentColumn] < stringEle.length()) { - fWidths[fCurrentColumn] = stringEle.length(); - } + EnsureCurrentColumnWidth(stringEle.length()); if (index == 0 || index == collectionSize - 1) { // Do nothing, by default DisplayElement is printed } else if (index == 1) { element.SetDots(); // Be sure the "..." fit - if (fWidths[fCurrentColumn] < 3) { - fWidths[fCurrentColumn] = 3; - } + EnsureCurrentColumnWidth(3); } else { // In the Print(), after the dots, all element will just be ignored except the last one. element.SetIgnore();