JDevlieghere 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); + ---------------- mib wrote: > Are we assuming that the number following `%` will always have a single digit > ? Added a comment to make it clear that atoi will parse until it encounters a character that's not a 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); ---------------- mib wrote: > 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. The formula you linked is to compute the size in bytes for the number, not the string length. Take `1` for example: floor(log10(1)) + 2 = 0 + 2 = 2. 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