Added $mem for converting MB to lhex and vise-versa#160
Open
chrisdodgers wants to merge 2 commits into
Open
Conversation
Aliases also include $fbmem, $stolenmem, $unifiedmem, $cursormem Usage example: $stolenmem 26m $fbmem 00009000
- Removed `mib = [“mib”, “mb”, “m”]` as it is unnecessarily redundant. Just checking for if `”m”` exists in the input value serves the same expected results determining if dealing with MiB input . - Removed `is_lhex`. Kind of pointless as if the input value doesn’t fall under `is_mib`, just assume its lhex. Any bad input values resulting in an error would just be caught in the try/except. - Removed the unnecessary string comparisons of `from_type` and `to_type`. Conversion logic for MiB -> lhex happens now in `if is_mib`, and `else` we do lhex -> MiB. - Removed the regex handling in `num` to strip `mib` from the input value. Instead, just simply only storing `0-9` and `.` in the float and ignoring any other character that may be in the input value. - Cleaned up the calculation for `bytes_val` by using `num * 1024 ** 2` instead of `num * 1024 *1024`. (And cleaned this up likewise in `mib_val`). - Removed `hex_val` and instead directly feeding `bytes_val` to `_convert_value` using `decimal` to `lhex32`. Using `lhex32` instead of originally `lhex` replaces the previous need of pre-formatting to get proper padding. - Removed the use of Nullify. The output of `_convert_value()` is already sanitized and can be fed directly to the ctx. Also it is not needed in the particular response in `except Exception`. Huge credit and thanks to @corpnewt for these clean up suggestions and points I originally overlooked.
Author
Huge credit and thanks to @corpnewt for these clean up suggestions and for pointing out things I originally overlooked. |
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.
Can also be used with the following aliases:
$fbmem,$stolenmem,$unifiedmem, and$cursormem.Usage example:
$stolenmem 26m$fbmem 00009000$mem 0x00000006$cursormem 1MB