Skip to content
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

clippy fixes #405

Merged
merged 1 commit into from
Jan 4, 2021
Merged

clippy fixes #405

merged 1 commit into from
Jan 4, 2021

Conversation

Dirbaio
Copy link
Member

@Dirbaio Dirbaio commented Jan 4, 2021

No description provided.

@Dirbaio Dirbaio force-pushed the clippytest branch 2 times, most recently from 1b6eb26 to 223047e Compare January 4, 2021 00:13
@Dirbaio Dirbaio changed the title clippy test clippy fixes Jan 4, 2021
@Dirbaio Dirbaio marked this pull request as ready for review January 4, 2021 00:19
@Dirbaio Dirbaio merged commit 2aede17 into master Jan 4, 2021
@Dirbaio Dirbaio deleted the clippytest branch January 4, 2021 00:22
@@ -88,11 +88,11 @@ impl<'a> Parser<'a> {

fn accept_digit(&mut self, hex: bool) -> Result<u8> {
let digit = self.advance()?;
if digit >= b'0' && digit <= b'9' {
if (b'0'..=b'9').contains(&digit) {

Choose a reason for hiding this comment

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

This might not be such a big deal, but does this generate code that is equally efficient?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not quite.I just tried the following patch in my project and it resulted in a small decrease in size:

diff --git a/src/parsers.rs b/src/parsers.rs
index bf87cdc..36bad29 100644
--- a/src/parsers.rs
+++ b/src/parsers.rs
@@ -88,11 +88,11 @@ impl<'a> Parser<'a> {

     fn accept_digit(&mut self, hex: bool) -> Result<u8> {
         let digit = self.advance()?;
-        if (b'0'..=b'9').contains(&digit) {
+        if digit >= b'0' && digit <= b'9' {
             Ok(digit - b'0')
-        } else if hex && (b'a'..=b'f').contains(&digit) {
+        } else if hex && digit >= b'a' && digit <= b'f' {
             Ok(digit - b'a' + 10)
-        } else if hex && (b'A'..=b'F').contains(&digit) {
+        } else if hex && digit >= b'A' && digit <= b'F' {
             Ok(digit - b'A' + 10)
         } else {
             Err(())

Before this change, the size was as follows:

section                 size        addr
.vector_table            336           0
.text                  41528         336
.rodata                 8496       41864

And after:

section                 size        addr
.vector_table            336           0
.text                  41404         336
.rodata                 8512       41740

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants