go/printer: don't emit unnecessary //line directives before empty lines
1) Split atLineBegin into its two components: writing of // line directives and writing of indentation (no functionality changes). 2) Don't call writeLineDirective at the beginning of a line if we're writing white space - it's not necessary. This is the bug fix. 3) Move testing of the SourcePos mode out of writeLineDirective and into the (single) caller. Clearer and more efficient. (Instead of these 3 changes one could also have simply called the original atLineBegin with position p.out rather than p.pos. This would have caused atLineBegin to not write a line directive. Factoring the code seemed like a cleaner and more direct approach.) Fixes #5945. Change-Id: Ia8710806b6d3d4e5044116b142c036a4ab5a1764 Reviewed-on: https://go-review.googlesource.com/44651Reviewed-by: Alan Donovan <adonovan@google.com>
Showing
Please register or sign in to comment