File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 5
5
6
6
using System ;
7
7
using System . IO ;
8
+ using System . Runtime . Intrinsics . X86 ;
8
9
using System . Threading . Tasks ;
10
+ using static System . Runtime . InteropServices . JavaScript . JSType ;
9
11
10
12
namespace SimpleBase ;
11
13
@@ -115,6 +117,12 @@ public int GetSafeByteCountForDecoding(ReadOnlySpan<char> text)
115
117
}
116
118
117
119
/// <inheritdoc/>
120
+ ///<remarks>
121
+ ///This formula overestimates the required size to the next multiplier of 8 characters
122
+ ///to leave space for the padding characters at the end. If this kind of generous
123
+ ///allocation is a problem, a different formula can be used with non-allocating encoding
124
+ ///functions like <see cref="TryEncode(ReadOnlySpan{byte}, Span{char}, out int)" />.
125
+ ///</remarks>
118
126
public int GetSafeCharCountForEncoding ( ReadOnlySpan < byte > buffer )
119
127
{
120
128
return ( ( ( buffer . Length - 1 ) / bitsPerChar ) + 1 ) * bitsPerByte ;
You can’t perform that action at this time.
0 commit comments