SavePersistent: Sort in name order, fix list commas.

This commit is contained in:
Peter Johnson
2015-07-19 21:10:20 -07:00
parent b0802f3e26
commit 8db016c223

View File

@@ -170,6 +170,10 @@ void Storage::SavePersistent(std::ostream& os) const {
}
}
// sort in name order
std::sort(entries.begin(), entries.end(),
[](const auto& a, const auto& b) { return a.first < b.first; });
std::string base64_encoded;
// header
@@ -229,10 +233,8 @@ void Storage::SavePersistent(std::ostream& os) const {
case NT_BOOLEAN_ARRAY: {
bool first = true;
for (auto elem : v->GetBooleanArray()) {
if (!first) {
os << ',';
first = false;
}
if (!first) os << ',';
first = false;
os << (elem ? "true" : "false");
}
break;
@@ -240,10 +242,8 @@ void Storage::SavePersistent(std::ostream& os) const {
case NT_DOUBLE_ARRAY: {
bool first = true;
for (auto elem : v->GetDoubleArray()) {
if (!first) {
os << ',';
first = false;
}
if (!first) os << ',';
first = false;
os << elem;
}
break;
@@ -251,10 +251,8 @@ void Storage::SavePersistent(std::ostream& os) const {
case NT_STRING_ARRAY: {
bool first = true;
for (auto& elem : v->GetStringArray()) {
if (!first) {
os << ',';
first = false;
}
if (!first) os << ',';
first = false;
WriteString(os, elem);
}
break;