ZipArchive icon indicating copy to clipboard operation
ZipArchive copied to clipboard

Use libdeflate [de]compressor under conditional compilation

Open wqweto opened this issue 6 years ago • 3 comments

Pros

  • better compression ratio
  • better decompression speed

Cons

wqweto avatar May 23 '19 17:05 wqweto

A few additional thoughts...

Pros

  • better compression speed (even at minimum comp. levels)
  • faster crc32

Cons

  • libdeflate only implements "one-shot" deflate/inflate API. There is no streaming API. Probably not a deal-breaker for most users, but this would prevent future Zip64 support (via libdeflate, anyway).

Misc

  • as noted in the libdeflate README, compiling via VS is "supported" but the perf hit is large. The recommended MinGW toolchain further complicates custom stdcall building (which is why I just stick with official binaries and DispCallFunc wrappers... it's ugly, but the perf benefits are worth it IMO)
  • if conditional compilation introduces too many complexities, another implementation option could be a public sub like...
Public Sub SetLibDeflatePath(pathToDll As String)
  mhLibDeflate = LoadLibrary(pathToDll)
  If (mhLibDeflate <> 0) Then
    'Cache proc addresses for relevant functions
  End If
End Sub

...with relevant deflate/inflate code gently modified...

If (mhLibDeflate <> 0) Then
   'Use libdeflate
Else
   'Use thunk
End If

Hard to know what is "best" for the average VB6 consumer of the class :/

tannerhelland avatar May 23 '19 19:05 tannerhelland

10x for input, Tanner.

I think gcc/mingw must support stdcall on x86 targets. Although still have to weight in benefits of using official release dlls against custom built stdcall ones.

wqweto avatar May 24 '19 12:05 wqweto

Yes, GCC does support stdcall exports, but I am fuzzy on "best practices" for handling things like name-mangling with it...

tbh I have moved more and more toward p/invoke-style DispCallFunc wrapping of official 3rd-party release builds in recent years, mostly because maintaining custom stdcall builds is tedious and I find few repo owners are interested in merging patches to simplify cross-building. But it's also entirely possible that I am just getting lazier... :)

Either way, thank you for investigating this feature! (And sorry for popping into this repo so often; it's one of the few I watch on GitHub as I've deployed it to quite a few client projects - across many production environments, it works excellently.)

tannerhelland avatar May 24 '19 14:05 tannerhelland