mib added inline comments.
================ Comment at: lldb/source/Commands/CommandObjectRegexCommand.cpp:38 + // Parse the number following '%'. + const size_t idx = std::atoi(str.c_str() + pos + 1); + ---------------- Are we assuming that the number following `%` will always have a single digit ? ================ Comment at: lldb/source/Commands/CommandObjectRegexCommand.cpp:50 + const std::string replacement(replacements[idx]); + const size_t pattern_size = 1 + static_cast<size_t>(log10(idx) + 1); + str.replace(pos, pattern_size, replacement); ---------------- TIL but I think the exact formula is `floor(log10(num))+2` according to this https://stackoverflow.com/questions/61707231/why-is-log-base-10-used-in-this-code-to-convert-int-to-string I don't know if this formula has a name but if it does it would be great to add it as a comment above. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120101/new/ https://reviews.llvm.org/D120101 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits