use unique_ptr<string> in ColStringValue to save space in variant
This commit is contained in:
10
usql.cpp
10
usql.cpp
@@ -504,6 +504,10 @@ std::unique_ptr<ValueNode> USql::eval_function_value_node(Table *table, Row &row
|
||||
evaluatedPars.push_back(eval_value_node(table, row, param.get()));
|
||||
}
|
||||
|
||||
// at this moment no functions without parameter(s) or first param can be null
|
||||
if (evaluatedPars.empty() || evaluatedPars[0]->isNull())
|
||||
return std::make_unique<NullValueNode>();
|
||||
|
||||
// TODO use some enum
|
||||
if (fnc->function == "lower") {
|
||||
std::string str = evaluatedPars[0]->getStringValue();
|
||||
@@ -533,7 +537,7 @@ std::unique_ptr<ValueNode> USql::eval_function_value_node(Table *table, Row &row
|
||||
|
||||
if (parsed_value->node_type == NodeType::int_value || parsed_value->node_type == NodeType::float_value) {
|
||||
std::string format = evaluatedPars.size() > 1 ? evaluatedPars[1]->getStringValue() : "";
|
||||
char buf[20] {0};
|
||||
char buf[16] {0};
|
||||
double value = parsed_value->getDoubleValue();
|
||||
|
||||
if (format == "100%")
|
||||
@@ -557,8 +561,8 @@ std::unique_ptr<ValueNode> USql::eval_function_value_node(Table *table, Row &row
|
||||
else if (value == 0)
|
||||
buf[0]='0';
|
||||
else
|
||||
return std::make_unique<StringValueNode>(parsed_value->getStringValue());
|
||||
|
||||
return std::make_unique<StringValueNode>(parsed_value->getStringValue().substr(0, 10));
|
||||
// TODO introduce constant for 10
|
||||
std::string s {buf};
|
||||
return std::make_unique<StringValueNode>(string_padd(s.erase(s.find_last_not_of(" ")+1), 10, ' ', false));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user