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

STRCSPN Modified to be more optimized on 64 bit proccessor's instead of 32bit #3

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@JohnEJames

JohnEJames commented Apr 11, 2017

This is my optimization for Spo Final Assignment.

I added optimization for 64 bit processors, and replace the return ternery statement with multiple if statements, to allow easier reading

@JohnEJames JohnEJames changed the title from Modified to be more optimized on 64 bit proccessor's instead of 32bit to STRCSPN Modified to be more optimized on 64 bit proccessor's instead of 32bit Apr 13, 2017

@JohnEJames

This comment has been minimized.

Show comment
Hide comment
@JohnEJames

JohnEJames commented Apr 13, 2017

Fixes #5

@@ -27,46 +27,65 @@
/* Return the length of the maximum initial segment of S
which contains no characters from REJECT. */
size_t
STRCSPN (const char *str, const char *reject)
size_t STRCSPN (const char *str, const char *reject)

This comment has been minimized.

@raygervais

raygervais Apr 13, 2017

Just a coding convention issue:
This goes against the convention found within the library. Though inconsistent, most variable types are declared on the previous line, such as the previous declaration of STRCSPN.

@raygervais

raygervais Apr 13, 2017

Just a coding convention issue:
This goes against the convention found within the library. Though inconsistent, most variable types are declared on the previous line, such as the previous declaration of STRCSPN.

{
if (__glibc_unlikely (reject[0] == '\0') ||
__glibc_unlikely (reject[1] == '\0'))
return __strchrnul (str, reject [0]) - str;
/* Use multiple small memsets to enable inlining on most targets. */
unsigned char table[256];
unsigned char *p = memset (table, 0, 64);

This comment has been minimized.

@raygervais

raygervais Apr 13, 2017

Similar to above, you'll notice that all functions have a space between the arguments and function name.
funcName (Args);

@raygervais

raygervais Apr 13, 2017

Similar to above, you'll notice that all functions have a space between the arguments and function name.
funcName (Args);

@raygervais

Just a stylistic change requested, the logic makes complete sense! 👍

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