Skip to content

Commit

Permalink
eliminate extra call to managed lib
Browse files Browse the repository at this point in the history
  • Loading branch information
aloneguid committed Jan 27, 2023
1 parent 2df486c commit 184aea0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
12 changes: 10 additions & 2 deletions managed/IronCompress/Iron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static bool SupportsManaged(Codec c) {
}

static bool SupportsNative(Codec c) {
return IsNativeLibraryAvailable && Native.is_supported((int)c);
return IsNativeLibraryAvailable && c != Codec.Gzip;
}

/// <summary>
Expand Down Expand Up @@ -87,7 +87,15 @@ public IronCompressResult Decompress(
Codec codec,
ReadOnlySpan<byte> input,
int? outputLength = null) {


if(ForcePlatform != null) {
if(ForcePlatform == Platform.Native) {
return NativeCompressOrDecompress(false, codec, input, CompressionLevel.NoCompression, outputLength);
} else if(ForcePlatform == Platform.Managed) {
return ManagedCompressOrDecompress(false, codec, input, CompressionLevel.NoCompression, outputLength);
}
}

if(SupportsNative(codec))
return NativeCompressOrDecompress(false, codec, input, CompressionLevel.NoCompression, outputLength);

Expand Down
9 changes: 0 additions & 9 deletions native/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,4 @@ bool compress(bool compress, int32_t codec, char* input_buffer, int32_t input_bu
}
}

bool is_supported(int32_t codec) {
return codec == 1 ||
codec == 2 ||
// not 3
codec == 4 ||
codec == 5 ||
codec == 6;
}

bool ping() { return true; }
7 changes: 0 additions & 7 deletions native/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ extern "C"
int32_t* output_buffer_size,
int32_t compression_level);

/**
* @brief Checks if particular codec is supported
* @param codec
* @return true if supported, false otherwise
*/
EXPORTED bool is_supported(int32_t codec);

/**
* @brief Used to just ping the library to test it's available at all
*/
Expand Down

0 comments on commit 184aea0

Please sign in to comment.