From ea31800f6194dbf45b530ab21049add076de52bd Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 20 Jul 2017 20:56:58 -0700 Subject: 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 Signed-off-by: Dirk Hohndel --- core/save-git.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'core') 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"); } -- cgit v1.2.3-70-g09d2