← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~hjd/widelands/more-empty-fixes into lp:widelands

 

Hans Joachim Desserud has proposed merging lp:~hjd/widelands/more-empty-fixes into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #986611 in widelands: "Issues reported by cppcheck"
  https://bugs.launchpad.net/widelands/+bug/986611

For more details, see:
https://code.launchpad.net/~hjd/widelands/more-empty-fixes/+merge/113828

When generating a new report for bug 986611, I noticed a few new places which used size() instead of empty().
-- 
https://code.launchpad.net/~hjd/widelands/more-empty-fixes/+merge/113828
Your team Widelands Developers is requested to review the proposed merge of lp:~hjd/widelands/more-empty-fixes into lp:widelands.
=== modified file 'src/logic/bob.cc'
--- src/logic/bob.cc	2012-04-07 09:19:29 +0000
+++ src/logic/bob.cc	2012-07-07 17:10:26 +0000
@@ -1178,7 +1178,7 @@
 	//  See bug #537392 for more information:
 	//   https://bugs.launchpad.net/widelands/+bug/537392
 	Bob & bob = get<Bob>();
-	if (!bob.m_stack.size() && !egbase().get_gametime())
+	if (bob.m_stack.empty() && !egbase().get_gametime())
 		if (upcast(Game, game, &egbase())) {
 			bob.init_auto_task(*game);
 		}

=== modified file 'src/logic/player.cc'
--- src/logic/player.cc	2012-06-06 17:34:09 +0000
+++ src/logic/player.cc	2012-07-07 17:10:26 +0000
@@ -1008,7 +1008,7 @@
 	//  as well of this change.
 	if (!m_team_player_uptodate)
 		update_team_players();
-	if (!forward && m_team_player.size()) {
+	if (!forward && !m_team_player.empty()) {
 		for (uint8_t j = 0; j < m_team_player.size(); ++j)
 			m_team_player[j]->see_node(map, first_map_field, f, gametime, true);
 	}
@@ -1040,7 +1040,7 @@
 	//  as well of this change.
 	if (!m_team_player_uptodate)
 		update_team_players();
-	if (!forward && m_team_player.size()) {
+	if (!forward && !m_team_player.empty()) {
 		for (uint8_t j = 0; j < m_team_player.size(); ++j)
 			m_team_player[j]->unsee_node(i, gametime, true);
 	}

=== modified file 'src/wui/game_tips.cc'
--- src/wui/game_tips.cc	2012-02-15 21:25:34 +0000
+++ src/wui/game_tips.cc	2012-07-07 17:10:26 +0000
@@ -54,7 +54,7 @@
 	for (uint8_t i = 0; i < names.size(); ++i)
 		load_tips(names[i]);
 
-	if (m_tips.size() > 0) {
+	if (!m_tips.empty()) {
 		// add visualization only if any tips are loaded
 		m_progressWindow.add_visualization(this);
 		m_registered = true;


Follow ups