From c9e8b95519070e4f20246cc709c6dcf9b48ad5b5 Mon Sep 17 00:00:00 2001 From: Simon Shanks Date: Wed, 12 Aug 2026 12:00:14 +0100 Subject: [PATCH] perf improvement to char array serialisation --- kx/c.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kx/c.cs b/kx/c.cs index 7f8e4a6..6f127eb 100644 --- a/kx/c.cs +++ b/kx/c.cs @@ -1174,7 +1174,7 @@ public static int n(object x) } if (x is char[] carray) { - return e.GetBytes(carray).Length; + return e.GetByteCount(carray); } return ((Array)x).Length; } @@ -2136,7 +2136,11 @@ private static int ns(string s) { int j = s.IndexOf('\0'); j = ((-1 < j) ? j : s.Length); +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER + return e.GetByteCount(s, 0, j); +#else return e.GetBytes(s.Substring(0, j)).Length; +#endif } private static string i2(int i)