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

seq: bitwise and instead of mod #5272

Merged
merged 1 commit into from
Apr 9, 2016
Merged

Conversation

cgundogan
Copy link
Member

space is expected to be a power of 2 -1.
x % y is the same as x & (y-1) if y is a power of 2.

This reduces the unittests by about 200 bytes for the samr21-xpro.

@cgundogan cgundogan added the Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation label Apr 8, 2016
@cgundogan cgundogan added this to the Release 2016.07 milestone Apr 8, 2016
@@ -64,7 +64,7 @@ seq16_t seq16_adds(seq16_t s, uint16_t n, uint16_t space)
return s;
}

return (space == UINT16_MAX) ? (s + n) : (s + n) % (space + 1);
return (space == UINT16_MAX) ? (s + n) : ((s + n) & space);
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated, but someone™ should add the assert above for cib ;)

@miri64
Copy link
Member

miri64 commented Apr 8, 2016

ACK and go when Murdock is happy.

@miri64 miri64 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Apr 8, 2016
@miri64 miri64 merged commit 7cc2a91 into RIOT-OS:master Apr 9, 2016
@cgundogan cgundogan deleted the pr/seq/enhance branch April 9, 2016 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants