1
0
mirror of https://github.com/pdewacht/brlaser synced 2025-07-18 23:09:45 +02:00

Misc cleanups, mostly in the test code

This commit is contained in:
Peter De Wachter
2015-01-31 23:13:48 +01:00
parent 4f1a00d46a
commit 1474716b27
3 changed files with 47 additions and 26 deletions

View File

@ -25,13 +25,18 @@
class block {
public:
block(): line_bytes_(0) {
lines_.reserve(max_lines_per_block_);
}
bool empty() const {
return line_bytes_ == 0;
}
void add_line(std::vector<uint8_t> &&line) {
assert(!line.empty());
assert(line_fits(line.size()));
line_bytes_ += line.size();
lines_.push_back(line);
lines_.emplace_back(line);
}
bool line_fits(unsigned size) {
@ -40,7 +45,7 @@ class block {
}
void flush(FILE *f) {
if (line_bytes_) {
if (!empty()) {
fprintf(f, "%dw%c%c",
line_bytes_ + 2, 0,
static_cast<int>(lines_.size()));