Giter VIP home page Giter VIP logo

Comments (3)

wqweto avatar wqweto commented on May 27, 2024

As far as I understand you want to skip output array resizing at line 1299

                If IsArray(OutputTarget) And .Size > 0 Then
                    ReDim OutputTarget(0 To .Size - 1) As Byte
                End If

Another strategy altogether is to implement VFS stream over your oversized buffer with naked pointer arithmetics and all. Check out sample cMemoryStream.cls for all the VszXxx function-prototypes (below VFS interface comment) as expected to be impl by your stream class.

For OutputTarget I suppose you can even skip VfsReadFile impl as it will never be called from Extract. Copy VfsSetFilePointer and VfsSetEndOfFile verbatim from cMemoryStream and VfsWriteFile boils down to a single CopyMemory call and m_lPosition adjustment.

Edit: You can check out cBufferStream since da52300 for sample impl of the idea above.

from ziparchive.

tannerhelland avatar tannerhelland commented on May 27, 2024

Many thanks, @wqweto. I didn't expect you to provide a workable sample for me, but your generosity is always a welcome surprise!

(Mostly I find it a little sad when people fork a repo and change many things, but never notify the original code owner of those changes, just in case they find something useful/interesting in it. Of course when the changes are low-quality and potentially dangerous like mine often are, maybe best not mention them... ;)

I will migrate this change to my own copy soon to try and eke a few more ms gain out of loading very large OpenRaster archives. Thank you again.

from ziparchive.

tannerhelland avatar tannerhelland commented on May 27, 2024

Apologies again for taking so long to revisit this.

After many rounds of perf-testing, the easiest solution proved to be just bypassing the need for .Extract() calls when possible. Most OpenRaster exporters write uncompressed layer PNGs to the zip container - a smart decision, since PNGs are already 90+% deflate'd, and another deflate pass on top gains little but takes forever.

So I just hacked together a small "peek"-like function to return the file offset, compression state, and compressed/original size of individual archive entries. If PNG files are uncompressed in the archive, I can just point the PNG decoder at their offset and parse them directly from disk, skipping the Extract stage entirely.

For the few bad ORA writers who do store deflated PNGs, existing .Extract() function still works fine! I may still drop in the new cBufferStream implementation you so helpfully provided, but profiling shows that time spent in inflate() far outweighs time spent in safearray allocation, so I probably fell victim to "premature optimization is the root of all evil" by targeting allocation perf first. (shrugs sheepishly)

Thank you again for the new example code in cBufferStream. I hope others find it useful too!

from ziparchive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.