erichkeane added a comment. We're C++17 compilation now, so we should be able to use `std::string_view` (and I think we're supposed to?).
================ Comment at: llvm/lib/Demangle/Demangle.cpp:31 std::string Result; - const char *S = MangledName.c_str(); + std::string Copy = MangledName.str(); + const char *S = Copy.data(); ---------------- `std::string` is implicitly constructible from a `std::string_view`, so I think on line 37 we can just do: `MangledName[0]` instead of `S[0]`, and just do `return MangledName` below, rather than constructing it every time, despite it being just destructed in every other branch. Though, I guess the 'gotcha' here is that despite everything else not modifying the `S` here, that we're no longer able to use strlen for the length. Perhaps this change should be more viral, in that the other demangle functions should take a `string_view` instead of a `const char *` as well. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148181/new/ https://reviews.llvm.org/D148181 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits