From 9b851b887d53280f168ca59a8828b35bd4960a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Tue, 14 Oct 2025 07:18:56 +0200 Subject: [PATCH] Inline more trivial functions --- std/encoding.d | 1 + std/math/traits.d | 1 + std/path.d | 1 + std/uni/package.d | 11 +++++++++++ std/utf.d | 4 +++- 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/std/encoding.d b/std/encoding.d index c7c161e7d4d..9ad22fbc628 100644 --- a/std/encoding.d +++ b/std/encoding.d @@ -1666,6 +1666,7 @@ Returns true if c is a valid code point Params: c = the code point to be tested */ +pragma(inline, true) bool isValidCodePoint(dchar c) @safe pure nothrow @nogc { return c < 0xD800 || (c >= 0xE000 && c < 0x110000); diff --git a/std/math/traits.d b/std/math/traits.d index 8aba6a6b1c6..1f5a4bacf3e 100644 --- a/std/math/traits.d +++ b/std/math/traits.d @@ -34,6 +34,7 @@ if (isFloatingPoint!(X)) { version (all) { + pragma(inline, true); return x != x; } else diff --git a/std/path.d b/std/path.d index 13694ee875e..9f6a775b01e 100644 --- a/std/path.d +++ b/std/path.d @@ -152,6 +152,7 @@ else static assert(0, "unsupported platform"); On Windows, this includes both $(D `\`) and $(D `/`). On POSIX, it's just $(D `/`). */ +pragma(inline, true) bool isDirSeparator(dchar c) @safe pure nothrow @nogc { if (c == '/') return true; diff --git a/std/uni/package.d b/std/uni/package.d index 34d15e034ba..bf36177ab72 100644 --- a/std/uni/package.d +++ b/std/uni/package.d @@ -1612,6 +1612,7 @@ string genUnrolledSwitchSearch(size_t size) @safe pure nothrow return code; } +pragma(inline, true) bool isPow2OrZero(size_t sz) @safe pure nothrow @nogc { // See also: std.math.isPowerOf2() @@ -9161,6 +9162,7 @@ public bool isWhite(dchar c) /++ Return whether `c` is a Unicode lowercase $(CHARACTER). +/ +pragma(inline, true) @safe pure nothrow @nogc bool isLower(dchar c) { @@ -9194,6 +9196,7 @@ bool isLower(dchar c) /++ Return whether `c` is a Unicode uppercase $(CHARACTER). +/ +pragma(inline, true) @safe pure nothrow @nogc bool isUpper(dchar c) { @@ -10433,6 +10436,7 @@ if (!isSomeString!S && (isRandomAccessRange!S && hasLength!S && hasSlicing!S && Returns whether `c` is a Unicode alphabetic $(CHARACTER) (general Unicode category: Alphabetic). +/ +pragma(inline, true) @safe pure nothrow @nogc bool isAlpha(dchar c) { @@ -10478,6 +10482,7 @@ bool isMark(dchar c) Returns whether `c` is a Unicode numerical $(CHARACTER) (general Unicode category: Nd, Nl, No). +/ +pragma(inline, true) @safe pure nothrow @nogc bool isNumber(dchar c) { @@ -10511,6 +10516,7 @@ bool isNumber(dchar c) `true` if the character is in the Alphabetic, Nd, Nl, or No Unicode categories +/ +pragma(inline, true) @safe pure nothrow @nogc bool isAlphaNum(dchar c) { @@ -10548,6 +10554,7 @@ bool isAlphaNum(dchar c) Returns whether `c` is a Unicode punctuation $(CHARACTER) (general Unicode category: Pd, Ps, Pe, Pc, Po, Pi, Pf). +/ +pragma(inline, true) @safe pure nothrow @nogc bool isPunctuation(dchar c) { @@ -10695,6 +10702,7 @@ bool isFormat(dchar c) Returns whether `c` is a Unicode Private Use $(CODEPOINT) (general Unicode category: Co). +/ +pragma(inline, true) @safe pure nothrow @nogc bool isPrivateUse(dchar c) { @@ -10707,6 +10715,7 @@ bool isPrivateUse(dchar c) Returns whether `c` is a Unicode surrogate $(CODEPOINT) (general Unicode category: Cs). +/ +pragma(inline, true) @safe pure nothrow @nogc bool isSurrogate(dchar c) { @@ -10716,6 +10725,7 @@ bool isSurrogate(dchar c) /++ Returns whether `c` is a Unicode high surrogate (lead surrogate). +/ +pragma(inline, true) @safe pure nothrow @nogc bool isSurrogateHi(dchar c) { @@ -10725,6 +10735,7 @@ bool isSurrogateHi(dchar c) /++ Returns whether `c` is a Unicode low surrogate (trail surrogate). +/ +pragma(inline, true) @safe pure nothrow @nogc bool isSurrogateLo(dchar c) { diff --git a/std/utf.d b/std/utf.d index 7db120befd5..e9713e6c293 100644 --- a/std/utf.d +++ b/std/utf.d @@ -271,7 +271,8 @@ if (isSomeChar!Char) `'\uFFFE'` and `'\uFFFF'` are considered valid by `isValidDchar`, as they are permitted for internal use by an application, but they are not allowed for interchange by the Unicode standard. - +/ + +/ +pragma(inline, true) bool isValidDchar(dchar c) pure nothrow @safe @nogc { return c < 0xD800 || (c > 0xDFFF && c <= 0x10FFFF); @@ -325,6 +326,7 @@ Params: Returns: `true`, if `c` forms a valid code point. */ +pragma(inline, true) bool isValidCodepoint(Char)(Char c) if (isSomeChar!Char) {