Skip to content

Commit

Permalink
ENH: Replace magic number by appropriate definition (from PR review)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmichel-otb committed Jul 7, 2016
1 parent 842bff5 commit 4713785
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions gdal/frmts/cderived/cderiveddataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ GDALDataset * ComplexDerivedDataset::Open(GDALOpenInfo * poOpenInfo)
CPLString filename(poOpenInfo->pszFilename);

/* DERIVED_SUBDATASET should be first domain */
size_t dsds_pos = filename.find("DERIVED_SUBDATASET:");
const size_t dsds_pos = filename.find("DERIVED_SUBDATASET:");
const size_t nPrefixLen = strlen("DERIVED_SUBDATASET:");

if (dsds_pos == std::string::npos)
{
Expand All @@ -65,14 +66,14 @@ GDALDataset * ComplexDerivedDataset::Open(GDALOpenInfo * poOpenInfo)
}

/* Next, we need to now which derived dataset to compute */
size_t alg_pos = filename.find(":",dsds_pos+20);
const size_t alg_pos = filename.find(":",dsds_pos+20);
if (alg_pos == std::string::npos)
{
/* Unable to Open if we do not find the name of the derived dataset */
return NULL;
}

CPLString odDerivedName = filename.substr(dsds_pos+19,alg_pos-dsds_pos-19);
CPLString odDerivedName = filename.substr(dsds_pos+nPrefixLen,alg_pos-dsds_pos-nPrefixLen);

CPLDebug("ComplexDerivedDataset::Open","Derived dataset requested: %s",odDerivedName.c_str());

Expand Down

0 comments on commit 4713785

Please sign in to comment.