cbor: Slight optimization
Optimize the cbor decoder slightly, saving 8-12 bytes of code.
Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/boot/bootutil/src/cbor.c b/boot/bootutil/src/cbor.c
index c925ca0..6df028d 100644
--- a/boot/bootutil/src/cbor.c
+++ b/boot/bootutil/src/cbor.c
@@ -58,17 +58,12 @@
data->base++;
data->len--;
return 0;
- } else if (ext == 24) {
- want = 1;
- } else if (ext == 25) {
- want = 2;
- } else if (ext == 26) {
- want = 4;
- } else {
- /* If we want uint64 support, add it above here. */
+ } else if (ext > 26) {
return -1;
}
+ want = 1 << (ext - 24);
+
if (data->len + 1 < want) {
return -1;
}