use unique_ptr<string> in ColStringValue to save space in variant
This commit is contained in:
21
row.cpp
21
row.cpp
@@ -20,8 +20,13 @@ int ColDoubleValue::compare(ColValue &other) {
|
||||
return c < 0 ? -1 : c == 0.0 ? 0 : 1;
|
||||
}
|
||||
|
||||
ColStringValue & ColStringValue::operator=(ColStringValue other) {
|
||||
std::swap(m_string, other.m_string);
|
||||
return *this;
|
||||
}
|
||||
|
||||
int ColStringValue::compare(ColValue &other) {
|
||||
return other.isNull() ? 1 : m_string.compare(other.getStringValue()); // null goes to end
|
||||
return other.isNull() ? 1 : m_string->compare(other.getStringValue()); // null goes to end
|
||||
}
|
||||
|
||||
int ColDateValue::compare(ColValue &other) {
|
||||
@@ -35,20 +40,8 @@ int ColBooleanValue::compare(ColValue &other) {
|
||||
return m_bool == other.getBoolValue() ? 0 : m_bool && !other.getBoolValue() ? -1 : 1; // true first
|
||||
}
|
||||
|
||||
Row::Row(int cols_count) {
|
||||
m_columns.reserve(cols_count);
|
||||
for (int i = 0; i < cols_count; i++) {
|
||||
m_columns.emplace_back(ColNullValue());
|
||||
}
|
||||
}
|
||||
|
||||
Row::Row(const Row &other) {
|
||||
m_columns.reserve(other.m_columns.size());
|
||||
Row::Row(const Row &other) : m_columns(other.m_columns.size(), ColNullValue()) {
|
||||
// PERF here we first set cols null and then immediately replace it
|
||||
for (int i = 0; i < other.m_columns.size(); i++) {
|
||||
m_columns.emplace_back(ColNullValue());
|
||||
}
|
||||
|
||||
for (int i = 0; i < other.m_columns.size(); i++) {
|
||||
if (other[i].isNull())
|
||||
continue; // for null NOP
|
||||
|
||||
Reference in New Issue
Block a user