TupleVariation.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:otRebuilder 作者: Pal3love 项目源码 文件源码
def decompileDeltas_(numDeltas, data, offset):
        """(numDeltas, data, offset) --> ([delta, delta, ...], newOffset)"""
        result = []
        pos = offset
        while len(result) < numDeltas:
            runHeader = byteord(data[pos])
            pos += 1
            numDeltasInRun = (runHeader & DELTA_RUN_COUNT_MASK) + 1
            if (runHeader & DELTAS_ARE_ZERO) != 0:
                result.extend([0] * numDeltasInRun)
            else:
                if (runHeader & DELTAS_ARE_WORDS) != 0:
                    deltas = array.array("h")
                    deltasSize = numDeltasInRun * 2
                else:
                    deltas = array.array("b")
                    deltasSize = numDeltasInRun
                deltas.fromstring(data[pos:pos+deltasSize])
                if sys.byteorder != "big":
                    deltas.byteswap()
                assert len(deltas) == numDeltasInRun
                pos += deltasSize
                result.extend(deltas)
        assert len(result) == numDeltas
        return (result, pos)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号