高效memcspn
有谁知道 memcspn 函数的有效实现吗?它的行为应该类似于 strcspn,但在内存缓冲区中查找跨度,而不是在以 null 结尾的字符串中查找跨度。目标编译器是 VisualC++ 。
谢谢, 卢卡
Does anyone know of an efficient implementation of a memcspn function?? It should behave like strcspn but look for the span in a memory buffer and not in a null terminated string. The target compiler is visualC++ .
Thanks,
Luca
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种近乎最佳的实现:
对于
set2
使用位数组而不是字节数组可能会更好,具体取决于算术或更多一点缓存抖动在您的计算机上是否更昂贵。One near-optimal implementation:
It might be better to use a bit array instead of a byte array for
set2
, depending on whether arithmetic or a little bit more cache thrashing is more expensive on your machine.编写此函数的低效实现似乎相当困难,TBH - 实现看起来非常简单,所以如果您无法在合理的时间范围内找到实现,我建议您自己编写此函数。
It would seem pretty difficult to write an inefficient implementation of this function, TBH - the implementation seems pretty straightforward, so I'd suggest writing this yourself if you can't find an implementation in a reasonable timeframe.