summaryrefslogtreecommitdiffstats
path: root/searchcommon
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahoo-inc.com>2017-04-05 11:04:36 +0000
committerGeir Storli <geirst@yahoo-inc.com>2017-04-05 11:04:36 +0000
commita36e7319891fbddcf23c71792b573335448afc61 (patch)
treecf2a715c23cb30365c5a871861565b96b276fd9d /searchcommon
parentae812c64492160223a0a3e674f38c2d5a59c2663 (diff)
Reuse result from static cast.
Diffstat (limited to 'searchcommon')
-rw-r--r--searchcommon/src/vespa/searchcommon/common/datatype.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/searchcommon/src/vespa/searchcommon/common/datatype.cpp b/searchcommon/src/vespa/searchcommon/common/datatype.cpp
index ef6dcfc3ad6..6b620e17195 100644
--- a/searchcommon/src/vespa/searchcommon/common/datatype.cpp
+++ b/searchcommon/src/vespa/searchcommon/common/datatype.cpp
@@ -50,12 +50,13 @@ const char *datatype_str[] = { "UINT1",
vespalib::string
getTypeName(DataType type) {
- if (static_cast<size_t>(type) > vespalib::arraysize(datatype_str)) {
+ size_t typeAsNum = static_cast<size_t>(type);
+ if (typeAsNum > vespalib::arraysize(datatype_str)) {
vespalib::asciistream ost;
- ost << "UNKNOWN(" << static_cast<size_t>(type) << ")";
+ ost << "UNKNOWN(" << typeAsNum << ")";
return ost.str();
}
- return datatype_str[static_cast<size_t>(type)];
+ return datatype_str[typeAsNum];
}
std::ostream &
@@ -81,12 +82,13 @@ const char *collectiontype_str[] = { "SINGLE",
vespalib::string
getTypeName(CollectionType type) {
- if (static_cast<size_t>(type) > vespalib::arraysize(collectiontype_str)) {
+ size_t typeAsNum = static_cast<size_t>(type);
+ if (typeAsNum > vespalib::arraysize(collectiontype_str)) {
vespalib::asciistream ost;
- ost << "UNKNOWN(" << static_cast<size_t>(type) << ")";
+ ost << "UNKNOWN(" << typeAsNum << ")";
return ost.str();
}
- return collectiontype_str[static_cast<size_t>(type)];
+ return collectiontype_str[typeAsNum];
}
std::ostream &