From 316b05cf34743902375e1d7d9afbe3ae6eb7e645 Mon Sep 17 00:00:00 2001 From: vitaut Date: Wed, 28 Oct 2015 06:31:37 -0700 Subject: [PATCH] Avoid magic constants --- format.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/format.cc b/format.cc index 262eda7e..abc5354e 100644 --- a/format.cc +++ b/format.cc @@ -444,16 +444,16 @@ class BasicArgFormatter : public ArgVisitor { typedef typename BasicWriter::CharPtr CharPtr; Char fill = internal::CharTraits::cast(spec_.fill()); CharPtr out = CharPtr(); - if (spec_.width_ > 1) { + enum { CHAR_WIDTH = 1 }; + if (spec_.width_ > CHAR_WIDTH) { out = writer_.grow_buffer(spec_.width_); if (spec_.align_ == ALIGN_RIGHT) { - std::fill_n(out, spec_.width_ - 1, fill); - out += spec_.width_ - 1; + std::fill_n(out, spec_.width_ - CHAR_WIDTH, fill); + out += spec_.width_ - CHAR_WIDTH; } else if (spec_.align_ == ALIGN_CENTER) { - // coverity[suspicious_sizeof] - out = writer_.fill_padding(out, spec_.width_, 1, fill); + out = writer_.fill_padding(out, spec_.width_, CHAR_WIDTH, fill); } else { - std::fill_n(out + 1, spec_.width_ - 1, fill); + std::fill_n(out + CHAR_WIDTH, spec_.width_ - CHAR_WIDTH, fill); } } else { out = writer_.grow_buffer(1);