Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

Improve use StringCursor instead index based char fetch#17

Merged
qingshi163 merged 4 commits into
RustPython:mainfrom
qingshi163:string-cursor
Jan 17, 2024
Merged

Improve use StringCursor instead index based char fetch#17
qingshi163 merged 4 commits into
RustPython:mainfrom
qingshi163:string-cursor

Conversation

@qingshi163

@qingshi163 qingshi163 commented Jan 13, 2024

Copy link
Copy Markdown
Contributor

#17

Comment thread src/string.rs
Comment on lines +2 to +5
pub struct StringCursor {
pub(crate) ptr: *const u8,
pub position: usize,
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this &[u8] or different to it?

e.g. will this version work?

pub struct StringCursor {
    bytes: &[u8],
}

cursor.bytes = ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nop, position is character position, ptr is bytes cursor.

@qingshi163 qingshi163 merged commit 21fc205 into RustPython:main Jan 17, 2024
@qingshi163 qingshi163 deleted the string-cursor branch January 17, 2024 14:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants