nim-lang / RFCs

A repository for your Nim proposals.
136 stars 26 forks source link

Fast substring match / contains #239

Closed FedericoCeratto closed 8 months ago

FedericoCeratto commented 4 years ago

strutils should provide a containsAt or matchAt proc to check if a string contains a substring at a given location. It's commonly used for implementing network protocols or file formats. It should use memcmp to benefit from SSE instructions and avoid loops or nested conditionals.

It could use toOpenArray or #178

Perhaps a similar proc should also exist for MemFiles

simonkrauter commented 4 years ago

There is strutils.continuesWith().

Araq commented 4 years ago

FWIW I have SSE optimized stdlib parsers in beta state.

juancarlospaco commented 4 years ago

contains is just convenience for find and find has start and end (?). :thinking:

FedericoCeratto commented 4 years ago

Having searched for "match", "contains", "substring" I could not find "continuesWith". Perhaps it could have a more intuitive alias.

FedericoCeratto commented 3 years ago

Previous discussion of SSE: https://github.com/nim-lang/Nim/issues/3155

github-actions[bot] commented 9 months ago

This RFC is stale because it has been open for 1095 days with no activity. Contribute a fix or comment on the issue, or it will be closed in 30 days.