-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[stdlib] Refactor atol
: StringRef
to StringSlice
and reusability
#3207
base: nightly
Are you sure you want to change the base?
Conversation
atol
for reusability5b8b424
to
05740d2
Compare
atol
: StringRef
to StringSlice
and reusability
So sorry this one fell off my radar and I'm just seeing this again now. I'm still +1 for the change. Do you mind rebasing? I know @martinvuyk has been working a lot in this area recently, so things may have changed quite a bit as we've been moving off of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't touched anything around atof and atol since I knew other people were working on it. Viewing the git blame it seems like this hasn't been touched since more than 6 months ago, so I think this will have trivial conflicts. @jjvraw Thanks again for working on this :)
stdlib/src/collections/string.mojo
Outdated
else: | ||
start = pos | ||
break | ||
var str_len = len(str_slice) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var str_len = len(str_slice) | |
var str_len = str_slice.byte_length() |
stdlib/src/collections/string.mojo
Outdated
fn _identify_base(str_ref: StringRef, start: Int) -> Tuple[Int, Int]: | ||
var length = len(str_ref) | ||
fn _identify_base(str_slice: StringSlice, start: Int) -> Tuple[Int, Int]: | ||
var length = len(str_slice) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var length = len(str_slice) | |
var length = str_slice.byte_length() |
- StringRef to StringSlice - Introduce _handle_base_prefix & _trim_and_handle_sign - Changed var to alias Signed-off-by: Joshua James Venter <[email protected]>
Signed-off-by: Joshua James Venter <[email protected]>
!sync |
✅🟣 This contribution has been merged 🟣✅ Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the nightly branch during the next Mojo nightly release, typically within the next 24-48 hours. We use Copybara to merge external contributions, click here to learn more. |
This pull request modularises previously inline code, assisting in addressing issue #2639 to allow
stol
function to reuse some of the functionality. These changes, initially part of PR #3178, have been separated for easier review.The refactoring extracts
_handle_base_prefix
&_trim_and_handle_sign
. Additionally, the docstring has been revised for clarity.Alongside these changes, the respective function signatures have been updated to move away from
StringRef
toStringSlice
.There was also a small
FIXME
to convert fromvar
toalias
, which is now seems possible.