diff options
author | Mathias Stearn <mathias@10gen.com> | 2012-11-20 16:58:06 -0500 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2012-11-26 14:38:13 -0500 |
commit | edb9482cb410e5b78830ad4e340e15479cb00526 (patch) | |
tree | 13c0c55ea81d77b616bf96153c01de628f6fab09 /src | |
parent | 00e5a9aada74de383d6d4f530c30af82e164e1d7 (diff) | |
download | mongo-edb9482cb410e5b78830ad4e340e15479cb00526.tar.gz |
Optimize ExpressionFieldPath
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/pipeline/expression.cpp | 5 | ||||
-rwxr-xr-x | src/mongo/db/pipeline/field_path.h | 4 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp index bf9586ad551..7e824c5d86d 100644 --- a/src/mongo/db/pipeline/expression.cpp +++ b/src/mongo/db/pipeline/expression.cpp @@ -1300,9 +1300,8 @@ namespace mongo { Value ExpressionFieldPath::evaluatePath(size_t index, size_t pathLength, Document pDocument) const { - Value pValue; /* the return value */ - - pValue = pDocument->getValue(fieldPath.getFieldName(index)); + // return value + Value pValue = pDocument->getValue(fieldPath.getFieldName(index)); /* if the field doesn't exist, quit with an undefined value */ if (pValue.missing()) diff --git a/src/mongo/db/pipeline/field_path.h b/src/mongo/db/pipeline/field_path.h index c3b9aa2a22c..4ff97817fbe 100755 --- a/src/mongo/db/pipeline/field_path.h +++ b/src/mongo/db/pipeline/field_path.h @@ -46,7 +46,7 @@ namespace mongo { @param i the zero based index of the path element. @returns the path element */ - string getFieldName(size_t i) const; + const string& getFieldName(size_t i) const; /** Get the full path. @@ -102,7 +102,7 @@ namespace mongo { return vFieldName.size(); } - inline string FieldPath::getFieldName(size_t i) const { + inline const string& FieldPath::getFieldName(size_t i) const { verify(i < getPathLength()); return vFieldName[i]; } |