Skip to content

Commit 184aea0

Browse files
committed
eliminate extra call to managed lib
1 parent 2df486c commit 184aea0

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

managed/IronCompress/Iron.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static bool SupportsManaged(Codec c) {
4343
}
4444

4545
static bool SupportsNative(Codec c) {
46-
return IsNativeLibraryAvailable && Native.is_supported((int)c);
46+
return IsNativeLibraryAvailable && c != Codec.Gzip;
4747
}
4848

4949
/// <summary>
@@ -87,7 +87,15 @@ public IronCompressResult Decompress(
8787
Codec codec,
8888
ReadOnlySpan<byte> input,
8989
int? outputLength = null) {
90-
90+
91+
if(ForcePlatform != null) {
92+
if(ForcePlatform == Platform.Native) {
93+
return NativeCompressOrDecompress(false, codec, input, CompressionLevel.NoCompression, outputLength);
94+
} else if(ForcePlatform == Platform.Managed) {
95+
return ManagedCompressOrDecompress(false, codec, input, CompressionLevel.NoCompression, outputLength);
96+
}
97+
}
98+
9199
if(SupportsNative(codec))
92100
return NativeCompressOrDecompress(false, codec, input, CompressionLevel.NoCompression, outputLength);
93101

native/api.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,4 @@ bool compress(bool compress, int32_t codec, char* input_buffer, int32_t input_bu
245245
}
246246
}
247247

248-
bool is_supported(int32_t codec) {
249-
return codec == 1 ||
250-
codec == 2 ||
251-
// not 3
252-
codec == 4 ||
253-
codec == 5 ||
254-
codec == 6;
255-
}
256-
257248
bool ping() { return true; }

native/api.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ extern "C"
3434
int32_t* output_buffer_size,
3535
int32_t compression_level);
3636

37-
/**
38-
* @brief Checks if particular codec is supported
39-
* @param codec
40-
* @return true if supported, false otherwise
41-
*/
42-
EXPORTED bool is_supported(int32_t codec);
43-
4437
/**
4538
* @brief Used to just ping the library to test it's available at all
4639
*/

0 commit comments

Comments
 (0)