Skip to content

Commit

Permalink
seq: bitwise and instead of mod
Browse files Browse the repository at this point in the history
  • Loading branch information
cgundogan committed Apr 8, 2016
1 parent 040ad55 commit 8a07982
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sys/seq/seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ seq8_t seq8_adds(seq8_t s, uint8_t n, uint8_t space)
return s;
}

return (space == UINT8_MAX) ? (s + n) : (s + n) % (space + 1);
return (space == UINT8_MAX) ? (s + n) : ((s + n) & space);
}

int seq8_compares(seq8_t s1, seq8_t s2, uint8_t space)
Expand Down Expand Up @@ -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);
}

int seq16_compares(seq16_t s1, seq16_t s2, uint16_t space)
Expand Down Expand Up @@ -98,7 +98,7 @@ seq32_t seq32_adds(seq32_t s, uint32_t n, uint32_t space)
return s;
}

return (space == UINT32_MAX) ? (s + n) : (s + n) % (space + 1);
return (space == UINT32_MAX) ? (s + n) : ((s + n) & space);
}

int seq32_compares(seq32_t s1, seq32_t s2, uint32_t space)
Expand Down Expand Up @@ -132,7 +132,7 @@ seq64_t seq64_adds(seq64_t s, uint64_t n, uint64_t space)
return s;
}

return (space == UINT64_MAX) ? (s + n) : (s + n) % (space + 1);
return (space == UINT64_MAX) ? (s + n) : ((s + n) & space);
}

int seq64_compares(seq64_t s1, seq64_t s2, uint64_t space)
Expand Down

0 comments on commit 8a07982

Please sign in to comment.