aboutsummaryrefslogtreecommitdiff
path: root/internal/format/packidx/lookup.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-06-14 15:03:33 +0000
committerGravatar Runxi Yu2026-06-14 15:03:33 +0000
commit40f90392528761b55f23af9ac2e24c1132a6cdc7 (patch)
treed24a82b51bf6b03d5b9166f17e47cd6a158999eb /internal/format/packidx/lookup.go
parentobject/store/packed/internal/ingest: Compare pack hashes too on bloom make (diff)
internal/format/packidx/lookup.go: Don't float HEAD main
Diffstat (limited to 'internal/format/packidx/lookup.go')
-rw-r--r--internal/format/packidx/lookup.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/internal/format/packidx/lookup.go b/internal/format/packidx/lookup.go
index a9196aff..e4b565b6 100644
--- a/internal/format/packidx/lookup.go
+++ b/internal/format/packidx/lookup.go
@@ -45,8 +45,9 @@ func (idx *Packidx) Lookup(oid []byte) (offset uint64, found bool, err error) {
case target >= hiKey:
mid = hi - 1
default:
- frac := float64(target-loKey) / float64(hiKey-loKey)
- mid = lo + int(frac*float64(hi-lo-1))
+ hi128, lo128 := bits.Mul64(target-loKey, uint64(hi-lo-1)) //#nosec G115
+ q, _ := bits.Div64(hi128, lo128, hiKey-loKey)
+ mid = lo + int(q) //#nosec G115
}
switch cmp := bytes.Compare(oid, idx.OIDAt(mid)); {