message: [terminal] Grid: code cleanup (prefer early abort).
diff: @@ -559,11 +559,15 @@ void Grid::clearHistory()
  void Grid::clampHistory()
  {
  - if (maxHistoryLineCount_.has_value())
  - {
  + if (!maxHistoryLineCount_.has_value())
  + return;
  +
  auto const actual = historyLineCount();
  - auto const expected = maxHistoryLineCount_.value();
  - auto const diff = actual > expected ? actual - expected : 0;
  + auto const maxHistoryLines = maxHistoryLineCount_.value();
  + if (actual < maxHistoryLines)
  + return;
  +
  + auto const diff = actual - maxHistoryLines;
  // any line that moves into history is using the default Wrappable flag.
  for (auto& line : lines(historyLineCount() - diff, historyLineCount()))
  @@ -579,7 +583,6 @@ void Grid::clampHistory()
  lines_.erase(begin(lines_), next(begin(lines_), diff));
  }
  -}
  void Grid::scrollUp(int _n, GraphicsAttributes const& _defaultAttributes, Margin const& _margin)
  {
  