terminal/src/inc/operators.hpp
Leonard Hecker a68b0d4f08
Introduce new TIL string helpers, teach older ones to use wmemcmp (#11725)
til::equals:
At the time of writing wmemcmp() is not an intrinsic for MSVC,
but the STL uses it to implement wide string comparisons.
This produces 3x the assembly _per_ comparison and increases
runtime by 2-3x for strings of medium length (16 characters)
and 5x or more for long strings (128 characters or more).
See: https://github.com/microsoft/STL/issues/2289

Additionally a number of case insensitive, locale unaware
helpers for prefix/suffix comparisons are introduced.
2021-11-17 23:42:40 +00:00

40 lines
837 B
C++

/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Module Name:
- operators.hpp
Abstract:
- This file contains helpful operator overloading for some older data structures.
Author(s):
- Austin Diviness (AustDi) Mar 2017
--*/
#pragma once
constexpr bool operator==(const COORD& a, const COORD& b) noexcept
{
return (a.X == b.X &&
a.Y == b.Y);
}
constexpr bool operator!=(const COORD& a, const COORD& b) noexcept
{
return !(a == b);
}
constexpr bool operator==(const SMALL_RECT& a, const SMALL_RECT& b) noexcept
{
return (a.Top == b.Top &&
a.Left == b.Left &&
a.Bottom == b.Bottom &&
a.Right == b.Right);
}
constexpr bool operator!=(const SMALL_RECT& a, const SMALL_RECT& b) noexcept
{
return !(a == b);
}