Skip to content

Instantly share code, notes, and snippets.

View strangezakary's full-sized avatar
:shipit:
Focusing

Zakary Strange strangezakary

:shipit:
Focusing
View GitHub Profile
@strangezakary
strangezakary / strlen.cpp
Created December 19, 2020 19:47
Really Fast String Length
// This Requires SSE 4.2, Steam hardware survey says this is supported on 97.81% of PCs
// This is REALLY fast, even with -O2 it usually beats the the CRT Implementation
//
// In most of my tests this is around 50x faster with small strings with -Od (with -O2 its closer to 10-15x faster)
//
static size_t
FastStringLength(char* String)
{
size_t Result = 0;
__m128i* Memory = (__m128i *)String;