diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-27 20:00:46 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-27 20:00:46 +0700 |
commit | ca24841d2e00c51a0a52df522139fcb096e0995f (patch) | |
tree | ea5d86bd2127a80ecc64a0b44f8b114f67291aef /crypto/src/openpgp | |
parent | Bcpg: update signature subpackets (diff) | |
download | BouncyCastle.NET-ed25519-ca24841d2e00c51a0a52df522139fcb096e0995f.tar.xz |
Use string.Create when available
Diffstat (limited to 'crypto/src/openpgp')
-rw-r--r-- | crypto/src/openpgp/SXprUtilities.cs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crypto/src/openpgp/SXprUtilities.cs b/crypto/src/openpgp/SXprUtilities.cs index d7969813f..835d3c347 100644 --- a/crypto/src/openpgp/SXprUtilities.cs +++ b/crypto/src/openpgp/SXprUtilities.cs @@ -34,6 +34,15 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp { int len = ReadLength(input, ch); +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + return string.Create(len, input, (chars, input) => + { + for (int i = 0; i < chars.Length; ++i) + { + chars[i] = Convert.ToChar(input.ReadByte()); + } + }); +#else char[] chars = new char[len]; for (int i = 0; i != chars.Length; i++) @@ -42,6 +51,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp } return new string(chars); +#endif } internal static byte[] ReadBytes(Stream input, int ch) |