diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-02 22:43:07 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-02 22:43:07 +0000 |
commit | ebb8b251c90b510a530d9ecd41e9c3c7ed78e1dd (patch) | |
tree | cfbd3c0cf03824ffcb4c8915e8b3e913b45c32e2 /ui/base | |
parent | da53133f7d014163eaa7f60dbe13ea093063469e (diff) | |
download | chromium_src-ebb8b251c90b510a530d9ecd41e9c3c7ed78e1dd.zip chromium_src-ebb8b251c90b510a530d9ecd41e9c3c7ed78e1dd.tar.gz chromium_src-ebb8b251c90b510a530d9ecd41e9c3c7ed78e1dd.tar.bz2 |
ui/base/models: Reverse the DCHECKs of index.
The way it's written until now is counter-intuitive. This makes it intuitive.
1 - To make sure an int index is in the array range when we are adding we should check for:
index >= 0 && index <= child_count().
So use DCHECK_GE for '>=' and DCHECK_LE for '<=' respectively.
2 - To make sure an int index is in the array range when we are retrieving it from vector we should check for:
index >= 0 && index < child_count().
So use DCHECK_GE for '>=' and DCHECK_LT for '<' respectively.
BUG=None
TEST=app_unittests --gtest_filter=TreeNodeModelTest.*
R=sky@chromium.org
Review URL: http://codereview.chromium.org/7058030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87716 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r-- | ui/base/models/tree_node_model.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ui/base/models/tree_node_model.h b/ui/base/models/tree_node_model.h index ef495b2..f4b41f8 100644 --- a/ui/base/models/tree_node_model.h +++ b/ui/base/models/tree_node_model.h @@ -74,8 +74,8 @@ class TreeNode : public TreeModelNode { // Adds |node| as a child of this one, at |index|. virtual void Add(NodeType* node, int index) { DCHECK(node); - DCHECK_LE(0, index); - DCHECK_GE(child_count(), index); + DCHECK_GE(index, 0); + DCHECK_LE(index, child_count()); // If the node has a parent, remove it from its parent. NodeType* parent = node->parent_; if (parent) @@ -116,8 +116,8 @@ class TreeNode : public TreeModelNode { // Returns the node at |index|. const NodeType* GetChild(int index) const { - DCHECK_LE(0, index); - DCHECK_GT(child_count(), index); + DCHECK_GE(index, 0); + DCHECK_LT(index, child_count()); return children_[index]; } NodeType* GetChild(int index) { |