HazardyKnusperkeks updated this revision to Diff 479189. HazardyKnusperkeks added a comment.
Reverted the changes in the switch. We now only have a fast path. On my machine 4 consecutive runs of the clang format unittests, the last three times (as reported by gtest) are: | | Before patch | After Patch | | Run 1 | 12769ms | 12535ms | | Run 2 | 13703ms | 12456ms | | Run 3 | 13305ms | 12470ms | | Avg | 13259ms | 12487ms | | That would be 6% speedup, more than I'd excpected. Release Build 32 Bit Windows. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138378/new/ https://reviews.llvm.org/D138378 Files: clang/lib/Format/WhitespaceManager.cpp Index: clang/lib/Format/WhitespaceManager.cpp =================================================================== --- clang/lib/Format/WhitespaceManager.cpp +++ clang/lib/Format/WhitespaceManager.cpp @@ -1430,10 +1430,14 @@ } // FIXME: This assert should hold if we computed the column correctly. // 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) { + ReplacementText.append(Spaces, ' '); + } else { + appendIndentText(ReplacementText, C.Tok->IndentLevel, Spaces, + std::max((int)C.StartOfTokenColumn, C.Spaces) - Spaces, + C.IsAligned); + } ReplacementText.append(C.CurrentLinePrefix); storeReplacement(C.OriginalWhitespaceRange, ReplacementText); }
Index: clang/lib/Format/WhitespaceManager.cpp =================================================================== --- clang/lib/Format/WhitespaceManager.cpp +++ clang/lib/Format/WhitespaceManager.cpp @@ -1430,10 +1430,14 @@ } // FIXME: This assert should hold if we computed the column correctly. // 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) { + ReplacementText.append(Spaces, ' '); + } else { + appendIndentText(ReplacementText, C.Tok->IndentLevel, Spaces, + std::max((int)C.StartOfTokenColumn, C.Spaces) - Spaces, + C.IsAligned); + } ReplacementText.append(C.CurrentLinePrefix); storeReplacement(C.OriginalWhitespaceRange, ReplacementText); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits