Conversation
KaoCC
requested changes
Apr 25, 2025
| OROASSERT( e == oroSuccess, 0 ); | ||
| } | ||
|
|
||
| void OrochiUtils::DecompressPrecompiled(std::vector<unsigned char>& out, const unsigned char* compressedInput, size_t compressedInput_sizeByte, size_t uncompressed_sizeByte) |
Collaborator
There was a problem hiding this comment.
This API relies on the special value (uncompressed_sizeByte > 0) to decide which action to take, which would be error-prone and not very user-friendly.
I suggest to change it to one of the followings:
Create another function to handle the "NOT compressed" case, and let this function to solely handle the data that are "compressed". Or you can rename the function and utilize function overloading.
- Rename the function (Maybe call it "HandlePrecompiled" ), and use
std::optional( e.g.,std::optional<size_t> uncompressed_sizeByte = std::nullopt)
and then you can check it like this:
if (uncompressed_sizeByte.has_value()) {
// handle decompression
} else {
// treat as raw input
}
Wrap the input into different structures:
struct CompressedBuffer {
const unsigned char* data;
size_t size;
size_t uncompressedSize;
};
struct RawBuffer {
const unsigned char* data;
size_t size;
};
And then you use function overloading such as:
static void HandlePrecompiled(std::vector<unsigned char>& out, const CompressedBuffer& buffer);
static void HandlePrecompiled(std::vector<unsigned char>& out, const RawBuffer& buffer);
KaoCC
approved these changes
Apr 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows us to compress the precompiled kernels that are embedded inside the HIPRT DLL.