Author: mordante
Date: Sun Apr 19 10:02:33 2009
New Revision: 35040
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35040&view=rev
Log:
Code cleanups.
Where possible changed the for loop to a foreach loop. delete 0 is valid so
remove the checks for that condition in the code.
Modified:
trunk/src/gui/widgets/grid.cpp
Modified: trunk/src/gui/widgets/grid.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.cpp?rev=35040&r1=35039&r2=35040&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.cpp (original)
+++ trunk/src/gui/widgets/grid.cpp Sun Apr 19 10:02:33 2009
@@ -33,12 +33,8 @@
tgrid::~tgrid()
{
- for(std::vector<tchild>::iterator itor = children_.begin();
- itor != children_.end(); ++itor) {
-
- if(itor->widget()) {
- delete itor->widget();
- }
+ foreach(tchild& child, children_) {
+ delete child.widget();
}
}
@@ -142,14 +138,11 @@
void tgrid::remove_child(const std::string& id, const bool find_all)
{
- for(std::vector<tchild>::iterator itor = children_.begin();
- itor != children_.end(); ++itor) {
-
- if(itor->id() == id) {
- if(itor->widget()) {
- delete itor->widget();
- }
- itor->set_widget(0);
+ foreach(tchild& child, children_) {
+
+ if(child.id() == id) {
+ delete child.widget();
+ child.set_widget(0);
if(!find_all) {
break;
@@ -160,10 +153,9 @@
void tgrid::set_active(const bool active)
{
- for(std::vector<tchild>::iterator itor = children_.begin();
- itor != children_.end(); ++itor) {
-
- twidget* widget = itor->widget();
+ foreach(tchild& child, children_) {
+
+ twidget* widget = child.widget();
if(!widget) {
continue;
}
@@ -393,11 +385,10 @@
bool tgrid::has_vertical_scrollbar() const
{
- for(std::vector<tchild>::const_iterator itor = children_.begin();
- itor != children_.end(); ++itor) {
+ foreach(const tchild& child, children_) {
// FIXME we should check per row and the entire row
// should have the flag!!!!
- if(itor->widget() && itor->widget()->has_vertical_scrollbar()) {
+ if(child.widget() && child.widget()->has_vertical_scrollbar()) {
return true;
}
}
@@ -476,11 +467,10 @@
bool tgrid::has_horizontal_scrollbar() const
{
- for(std::vector<tchild>::const_iterator itor = children_.begin();
- itor != children_.end(); ++itor) {
+ foreach(const tchild& child, children_) {
// FIXME we should check per column and the entire column
// should have the flag!!!!
- if(itor->widget() &&
itor->widget()->has_horizontal_scrollbar()) {
+ if(child.widget() &&
child.widget()->has_horizontal_scrollbar()) {
return true;
}
}
@@ -872,10 +862,8 @@
bool tgrid::has_widget(const twidget* widget) const
{
- for(std::vector<tchild>::const_iterator itor = children_.begin();
- itor != children_.end(); ++itor) {
-
- if(itor->widget() == widget) {
+ foreach(const tchild& child, children_) {
+ if(child.widget() == widget) {
return true;
}
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits