aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2017-07-20 20:56:58 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-07-21 16:33:45 -0700
commitea31800f6194dbf45b530ab21049add076de52bd (patch)
tree41bd46bb23c298bedf6cd8910a8a5b98a0f4be7e
parent1e38d9239a7bac621eedcb2bab98b90d78b988af (diff)
downloadsubsurface-ea31800f6194dbf45b530ab21049add076de52bd.tar.gz
git save format: don't save redundant sample information
When we load sample data from a git save-file, we always default to using the state from the previous sample (except for the special case of cylinder pressure where an empty value does not mean "same", but "interpolate", see core/load-git.c: new_sample()). But the corollary to that is that it's always redundant to save sample data that hasn't changed since the previous sample. For some reason, the rbt, bearing and heartrate sample data didn't follow that rule, and instead saved with lots of extra reduncancy. (The alternative would be to clear those samples at load time, and make them act like the pressure data, but it would appear that all these three values may as well just have the normal "if no change, don't save them" semantics). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--core/save-git.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/core/save-git.c b/core/save-git.c
index 9979aaf00..2647b88ae 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -286,8 +286,10 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl
old->cns = sample->cns;
}
- if (sample->rbt.seconds)
+ if (sample->rbt.seconds != old->rbt.seconds) {
put_format(b, " rbt=%u:%02u", FRACTION(sample->rbt.seconds, 60));
+ old->rbt.seconds = sample->rbt.seconds;
+ }
if (sample->o2sensor[0].mbar != old->o2sensor[0].mbar) {
put_milli(b, " sensor1=", sample->o2sensor[0].mbar, "bar");
@@ -308,8 +310,14 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl
put_milli(b, " po2=", sample->setpoint.mbar, "bar");
old->setpoint = sample->setpoint;
}
- show_index(b, sample->heartbeat, "heartbeat=", "");
- show_index(b, sample->bearing.degrees, "bearing=", "°");
+ if (sample->heartbeat != old->heartbeat) {
+ show_index(b, sample->heartbeat, "heartbeat=", "");
+ old->heartbeat = sample->heartbeat;
+ }
+ if (sample->bearing.degrees != old->bearing.degrees) {
+ show_index(b, sample->bearing.degrees, "bearing=", "°");
+ old->bearing.degrees = sample->bearing.degrees;
+ }
put_format(b, "\n");
}