From b4df876cf333439fc5d60855ba48f8950a6bd2d0 Mon Sep 17 00:00:00 2001 From: Ismail Khoffi Date: Mon, 4 Mar 2024 15:13:51 +0100 Subject: [PATCH] Try optimization: only add required shards errorBits/errLocs --- leopard.go | 6 +++--- leopard8.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/leopard.go b/leopard.go index 3fcecd6..098c1b3 100644 --- a/leopard.go +++ b/leopard.go @@ -430,19 +430,19 @@ func (r *leopardFF16) reconstruct(shards [][]byte, recoverAll bool, required []b for i := 0; i < r.parityShards; i++ { if len(shards[i+r.dataShards]) == 0 { errLocs[i] = 1 - if LEO_ERROR_BITFIELD_OPT && recoverAll { + if LEO_ERROR_BITFIELD_OPT && (recoverAll || (required != nil && required[i])) { errorBits.set(i) } } } for i := r.parityShards; i < m; i++ { errLocs[i] = 1 - if LEO_ERROR_BITFIELD_OPT && recoverAll { + if LEO_ERROR_BITFIELD_OPT && (recoverAll || (required != nil && required[i])) { errorBits.set(i) } } for i := 0; i < r.dataShards; i++ { - if len(shards[i]) == 0 { + if len(shards[i]) == 0 && (recoverAll || (required != nil && required[i])) { errLocs[i+m] = 1 if LEO_ERROR_BITFIELD_OPT { errorBits.set(i + m) diff --git a/leopard8.go b/leopard8.go index 2ba1e56..c0855ff 100644 --- a/leopard8.go +++ b/leopard8.go @@ -467,19 +467,19 @@ func (r *leopardFF8) reconstruct(shards [][]byte, recoverAll bool, required []bo for i := 0; i < r.parityShards; i++ { if len(shards[i+r.dataShards]) == 0 { errLocs[i] = 1 - if LEO_ERROR_BITFIELD_OPT && recoverAll { + if LEO_ERROR_BITFIELD_OPT && (recoverAll || required[i]) { errorBits.set(i) } } } for i := r.parityShards; i < m; i++ { errLocs[i] = 1 - if LEO_ERROR_BITFIELD_OPT && recoverAll { + if LEO_ERROR_BITFIELD_OPT && (recoverAll || required[i]) { errorBits.set(i) } } for i := 0; i < r.dataShards; i++ { - if len(shards[i]) == 0 { + if len(shards[i]) == 0 && (recoverAll || required[i]) { errLocs[i+m] = 1 if LEO_ERROR_BITFIELD_OPT { errorBits.set(i + m)