diff --git a/ReactCommon/fabric/view/conversions.h b/ReactCommon/fabric/view/conversions.h index 4f129c2a928d60..cec142a7b94968 100644 --- a/ReactCommon/fabric/view/conversions.h +++ b/ReactCommon/fabric/view/conversions.h @@ -337,16 +337,25 @@ inline std::string toString(const std::array &value) } inline std::string toString(const std::array &value) { - return "{" + - toString(value[0]) + ", " + - toString(value[1]) + ", " + - toString(value[2]) + ", " + - toString(value[3]) + ", " + - toString(value[4]) + ", " + - toString(value[5]) + ", " + - toString(value[6]) + ", " + - toString(value[7]) + ", " + - toString(value[8]) + "}"; + static std::array names = { + {"left", "top", "right", "bottom", "start", "end", "horizontal", "vertical", "all"} + }; + + std::string result; + std::string separator = ", "; + + for (int i = 0; i < YGEdgeCount; i++) { + if (value[i].unit == YGUnitUndefined) { + continue; + } + result += names[i] + ": " + toString(value[i]) + separator; + } + + if (!result.empty()) { + result.erase(result.length() - separator.length()); + } + + return "{" + result + "}"; } } // namespace react