提交 76e2e86e 编写于 作者: H Heejae Chang

increased threshold to follow consts in source text

上级 e62ef389
......@@ -196,6 +196,9 @@ public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, Synta
text.Lines.IndexOf(token1.Span.End) == text.Lines.IndexOf(token2.SpanStart);
}
// 32KB. comes from SourceText char buffer size and less than large object size
internal const int SourceTextLengthThreshold = 32 * 1024 / sizeof(char);
public static void WriteTo(this SourceText sourceText, ObjectWriter writer, CancellationToken cancellationToken)
{
// Source length
......@@ -203,7 +206,7 @@ public static void WriteTo(this SourceText sourceText, ObjectWriter writer, Canc
writer.WriteInt32(length);
// if source is small, no point on optimizing. just write out string
if (length < SharedPools.ByteBufferSize)
if (length < SourceTextLengthThreshold)
{
writer.WriteString(sourceText.ToString());
}
......@@ -277,7 +280,7 @@ private class ObjectReaderTextReader : TextReaderWithLength
public static TextReader Create(ObjectReader reader)
{
var length = reader.ReadInt32();
if (length < SharedPools.ByteBufferSize)
if (length < SourceTextLengthThreshold)
{
// small size, read as string
return new StringReader(reader.ReadString());
......
......@@ -17,7 +17,7 @@ public void TestSourceTextSerialization()
{
var textService = new DesktopTextFactoryService();
var maxSize = SharedPools.ByteBufferSize * 3;
var maxSize = SourceTextExtensions.SourceTextLengthThreshold * 3;
var sb = new StringBuilder(0, maxSize);
for (var i = 0; i < maxSize; i++)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册