This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add strstr implementation.
ClosedPublic

Authored by cgyurgyik on Jul 16 2020, 8:33 AM.

Details

Summary

[libc] Adds a simple strstr implementation as well as unit tests. This will be improved in follow-up revisions.

Diff Detail

Event Timeline

cgyurgyik created this revision.Jul 16 2020, 8:33 AM
cgyurgyik updated this revision to Diff 278643.Jul 16 2020, 5:37 PM
sivachandra added inline comments.Jul 20 2020, 10:00 AM
libc/src/string/strstr.cpp
18

You shouldn't need strlen even for a brute force implementation unless a future update will call strlen. Even then, doesn't seem like using strlen should be used until we really need it.

26

This declaration can be moved within the outer for loop?

cgyurgyik edited the summary of this revision. (Show Details)
cgyurgyik marked 3 inline comments as done.
cgyurgyik added inline comments.
libc/src/string/strstr.cpp
18

You're right. Fixed, thanks.

sivachandra accepted this revision.Jul 20 2020, 11:11 PM
sivachandra added inline comments.
libc/src/string/strstr.cpp
17

Nitty comment on a comment: Remove (and will) :)

This revision is now accepted and ready to land.Jul 20 2020, 11:11 PM
cgyurgyik updated this revision to Diff 279534.Jul 21 2020, 8:36 AM
cgyurgyik marked an inline comment as done.
cgyurgyik marked an inline comment as done.
This revision was automatically updated to reflect the committed changes.