diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-12 21:45:45 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-12 21:45:45 +0100 |
commit | edc827077ecf7984f23d8273cd1b3456d470e621 (patch) | |
tree | 655895e7c3749b18c9bd52cf48f8532e5f8d94ab /AK/StdLibExtras.h | |
parent | 6b4e88b51587153dceb8855e4f573694bf6a15c2 (diff) | |
download | serenity-edc827077ecf7984f23d8273cd1b3456d470e621.zip |
Optimize WindowManager::flush() with fast_dword_copy().
Diffstat (limited to 'AK/StdLibExtras.h')
-rw-r--r-- | AK/StdLibExtras.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 64892b041d..3de6598cb2 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -13,6 +13,36 @@ #include <utility> #endif +ALWAYS_INLINE void fast_dword_copy(dword* dest, const dword* src, size_t count) +{ +#ifdef SERENITY + asm volatile( + "rep movsl\n" + : "=S"(src), "=D"(dest) + : "S"(src), "D"(dest), "c"(count) + : "memory" + ); +#else + memcpy(dest, src, count * sizeof(dword)); +#endif +} + +ALWAYS_INLINE void fast_dword_fill(dword* dest, dword value, size_t count) +{ +#ifdef SERENITY + asm volatile( + "rep stosl\n" + : "=D"(dest) + : "D"(dest), "c"(count), "a"(value) + : "memory" + ); +#else + for (size_t i = 0; x <= count; ++x) { + dest[i] = value; + } +#endif +} + namespace AK { template<typename T> |