You could make this buffer be static so it is only initialized once, then just read/write from it. Integer logic is less time consuming than this allocation probably is. This holds true for all `vector` buffers you use.

Don't bother clearing it each time, unless GifLib says it won't write unless it needs to. Otherwise, just keep track of the count that you need and use that. Calling `vector::clear()` is O(n) so be careful as it will take a long time to do.. either it will reallocate the entire array OR it will go one by one and "null" the entries. I think the former. 

Yeah, I've looked further, this is probably the easiest and best optimization that you can do at this point.