Skip to content

Commit 93ea8ae

Browse files
committed
emit early comma (#4)
1 parent ba724cf commit 93ea8ae

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

examples/sd-server/main.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,19 +1780,13 @@ class StreamingImageResponder {
17801780
array_opened_ = true;
17811781
}
17821782

1783-
if (!first_object_) {
1784-
const char separator[] = ",\n";
1785-
if (!sink.write(separator, sizeof(separator) - 1)) {
1786-
return false;
1787-
}
1788-
sink.os.flush();
1789-
}
1790-
17911783
std::string chunk = std::move(serialized);
17921784
if (final_item) {
17931785
chunk.append("\n]");
1786+
chunk.push_back('\n');
1787+
} else {
1788+
chunk.append(",\n");
17941789
}
1795-
chunk.push_back('\n');
17961790
bool ok = sink.write(chunk.data(), chunk.size());
17971791
if (ok) {
17981792
sink.os.flush();
@@ -3413,6 +3407,11 @@ bool parse_convert_request(const json& body, ConvertRequest& request, std::strin
34133407
return false;
34143408
}
34153409
std::string qtype_value = to_lower_copy(trim_copy(qtype_it->get<std::string>()));
3410+
for (size_t i = 0; i + 1 < qtype_value.size(); ++i) {
3411+
if (qtype_value[i] == '_' && qtype_value[i + 1] == 'k') {
3412+
qtype_value[i + 1] = 'K';
3413+
}
3414+
}
34163415
if (qtype_value.empty()) {
34173416
error = "field 'qtype' must not be empty";
34183417
return false;

0 commit comments

Comments
 (0)