upgrade .SerializeInstructionSequences() to the crazy checkpointing scheme.

This commit is contained in:
fiatjaf
2023-09-30 13:14:40 -03:00
parent ef94324f2e
commit 402291008e
5 changed files with 134 additions and 70 deletions

View File

@@ -20,7 +20,7 @@ type Buffer struct {
buf []byte
}
func NewBuffer(buf []byte) Buffer {
func newBuffer(buf []byte) Buffer {
zero := 0
return Buffer{&zero, buf}
}
@@ -99,3 +99,13 @@ func appendVarBytes(buf []byte, value []byte) []byte {
buf = append(buf, value...)
return buf
}
func getCommonPrefixIndex(s1 []Instruction, s2 []Instruction) int {
n := min(len(s1), len(s2))
for i := 0; i < n; i++ {
if CompareInstructions(s1[i], s2[i]) != 0 {
return i
}
}
return n
}