[PATCH] D138378: [clang-format][NFC] Skip unneeded calculations

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 20 19:00:57 PST 2022


owenpan added inline comments.


================
Comment at: clang/lib/Format/WhitespaceManager.cpp:1433
       // assert((int)C.StartOfTokenColumn >= C.Spaces);
-      appendIndentText(
-          ReplacementText, C.Tok->IndentLevel, std::max(0, C.Spaces),
-          std::max((int)C.StartOfTokenColumn, C.Spaces) - std::max(0, C.Spaces),
-          C.IsAligned);
+      unsigned Spaces = std::max(0, C.Spaces);
+      if (Style.UseTab == FormatStyle::UT_Never) {
----------------
So that we don't have to worry about `signed` vs `unsigned`.


================
Comment at: clang/lib/Format/WhitespaceManager.cpp:1434-1436
+      if (Style.UseTab == FormatStyle::UT_Never) {
+        ReplacementText.append(Spaces, ' ');
+      } else {
----------------
Doing this would lose some of the abstraction we have now without any gain in performance? Then we should leave it (and `appendIndentText` below) as is.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138378/new/

https://reviews.llvm.org/D138378



More information about the cfe-commits mailing list