cmListCommand: Move size variable out of loop.
Re-use it where possible in two instances.
This commit is contained in:
parent
10e53e2308
commit
75661fdfd9
@ -202,12 +202,12 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args)
|
|||||||
std::string value;
|
std::string value;
|
||||||
size_t cc;
|
size_t cc;
|
||||||
const char* sep = "";
|
const char* sep = "";
|
||||||
|
size_t nitem = varArgsExpanded.size();
|
||||||
for ( cc = 2; cc < args.size()-1; cc ++ )
|
for ( cc = 2; cc < args.size()-1; cc ++ )
|
||||||
{
|
{
|
||||||
int item = atoi(args[cc].c_str());
|
int item = atoi(args[cc].c_str());
|
||||||
value += sep;
|
value += sep;
|
||||||
sep = ";";
|
sep = ";";
|
||||||
size_t nitem = varArgsExpanded.size();
|
|
||||||
if ( item < 0 )
|
if ( item < 0 )
|
||||||
{
|
{
|
||||||
item = (int)nitem + item;
|
item = (int)nitem + item;
|
||||||
@ -216,8 +216,8 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args)
|
|||||||
{
|
{
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << "index: " << item << " out of range (-"
|
str << "index: " << item << " out of range (-"
|
||||||
<< varArgsExpanded.size() << ", "
|
<< nitem << ", "
|
||||||
<< varArgsExpanded.size()-1 << ")";
|
<< nitem - 1 << ")";
|
||||||
this->SetError(str.str());
|
this->SetError(str.str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -485,10 +485,10 @@ bool cmListCommand::HandleRemoveAtCommand(
|
|||||||
|
|
||||||
size_t cc;
|
size_t cc;
|
||||||
std::vector<size_t> removed;
|
std::vector<size_t> removed;
|
||||||
|
size_t nitem = varArgsExpanded.size();
|
||||||
for ( cc = 2; cc < args.size(); ++ cc )
|
for ( cc = 2; cc < args.size(); ++ cc )
|
||||||
{
|
{
|
||||||
int item = atoi(args[cc].c_str());
|
int item = atoi(args[cc].c_str());
|
||||||
size_t nitem = varArgsExpanded.size();
|
|
||||||
if ( item < 0 )
|
if ( item < 0 )
|
||||||
{
|
{
|
||||||
item = (int)nitem + item;
|
item = (int)nitem + item;
|
||||||
@ -497,8 +497,8 @@ bool cmListCommand::HandleRemoveAtCommand(
|
|||||||
{
|
{
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << "index: " << item << " out of range (-"
|
str << "index: " << item << " out of range (-"
|
||||||
<< varArgsExpanded.size() << ", "
|
<< nitem << ", "
|
||||||
<< varArgsExpanded.size()-1 << ")";
|
<< nitem - 1 << ")";
|
||||||
this->SetError(str.str());
|
this->SetError(str.str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user