Flash 优化ByteArray复制

Flash 优化ByteArray复制,flash,actionscript-3,apache-flex,optimization,bytearray,Flash,Actionscript 3,Apache Flex,Optimization,Bytearray,下面是来自flashlight VNC库的代码片段,它解压缩(使用ByteArray.inflate)传入的字节流 package com.flashlight.zlib { import com.flashlight.utils.TimeTracker; import flash.utils.ByteArray; import mx.logging.ILogger; import mx.logging.Log; public class Infl

下面是来自flashlight VNC库的代码片段,它解压缩(使用ByteArray.inflate)传入的字节流

package com.flashlight.zlib
{

    import com.flashlight.utils.TimeTracker;

    import flash.utils.ByteArray;

    import mx.logging.ILogger;
    import mx.logging.Log;

    public class Inflater {
        private var lastDeflate:ByteArray;

        public function uncompress(compressedData:ByteArray):ByteArray {
            var uncompressedData:ByteArray = new ByteArray();
            var dataOffset:int = lastDeflate ? 0 : 2;

            TimeTracker.startTimer("TightEncoding[CopyCompresion]");
            if (lastDeflate) {
                var dictionarySize:int = lastDeflate.length > 32768 ? 32768 : lastDeflate.length;
                uncompressedData.writeByte(0x00);
                uncompressedData.writeByte(dictionarySize );
                uncompressedData.writeByte(dictionarySize >> 8);
                uncompressedData.writeByte(~dictionarySize);
                uncompressedData.writeByte((~dictionarySize) >> 8 );
                uncompressedData.writeBytes(lastDeflate,lastDeflate.length - dictionarySize, dictionarySize);
            }
            uncompressedData.writeBytes(compressedData,dataOffset,compressedData.length-dataOffset);
            TimeTracker.stopTimer("TightEncoding[CopyCompresion]");
            uncompressedData.writeByte(0x01);
            uncompressedData.writeUnsignedInt(0x0000FFFF);

            TimeTracker.startTimer("TightEncoding[Realdecompress]");
            uncompressedData.inflate(); 
            TimeTracker.stopTimer("TightEncoding[Realdecompress]");

            lastDeflate = uncompressedData;
            uncompressedData.position = dictionarySize;

            return uncompressedData;
        }

    }
}
来自服务器的压缩数据流是恒定的,由充气器类逐块充气。在这个类中,膨胀()和writeBytes()方法总共占用99%的时间。inflate()已经是本机调用


如何优化writeBytes调用?我们可以跳过它,以其他方式重新连接代码,还是有更好的优化方法来执行ByteArray复制操作?

不确定ByteArray是否可以优化,只要它是本机Flash类。我想你可以尝试一些第三方库/框架,比如氟或炼金术,调用C++算法,可以更快。

我尝试过,对于CPU广泛的“to”循环,但是通过BurtRay-Rad需要大量的时间:(我现在正在寻找HAXE/AZOM,以提高BurtRayRayPipe性能。