Optimize __ziplistCascadeUpdate algorithm (#6886)
Optimize __ziplistCascadeUpdate algorithm (#6886)

The previous algorithm is of O(n^2) time complexity.
It would have run through the ziplist entries one by one, each time doing a `realloc` and a
`memmove` (moving the entire tail of the ziplist).

The new algorithm is O(n), it runs over all the records once, computing the size of the `realloc`
needed, then does one `realloc`, and run thought the records again doing many smaller `memmove`s,
each time moving just one record.

So this change reduces many reallocs, and moves each record just once.

Co-authored-by: zhumaohua <11ec0306b8920fdee4005d1d2aa3a926fd7d2aef@megvii.com>
Co-authored-by: Oran Agra <4bc4982385244a2789f53ac695e2aa0ced00df6d@redislabs.com>
JackieXie168/redis,JackieXie168/redis,JackieXie168/redis,JackieXie168/redis