avoid string operations on numbers#47
Open
shaydo-deriv wants to merge 1 commit intoderiv-com:masterfrom
Open
Conversation
multiple methods use regex to check if input argument is a number, this is rather inefficient and to add to that if it is not a number, these methods simply return unchanged input value without indicating an error in any way. _round_to_precision method in addition to that converts $precision value to a string for the sake of rounding it, prepends it with "-" and then parses the result back to number. This logic is hard to understand and it is also not very efficient.
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.
multiple methods use regex to check if input argument is a number, this is rather inefficient and to add to that if it is not a number, these methods simply return unchanged input value without indicating an error in any way.
_round_to_precision method in addition to that converts $precision value to a string for the sake of rounding it, prepends it with "-" and then parses the result back to number. This logic is hard to understand and it is also not very efficient.