-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix Console.Write on iOS #56713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Console.Write on iOS #56713
Changes from 1 commit
71b3888
8f6f7bc
a97f0d5
90bf33c
e6806e4
2bdb6e7
612dc1c
6f8542b
47d8f01
4f0653a
14545a8
725e64c
5b8499c
61bb68b
68e10e7
ac45868
2e57d54
c8aa30f
b76ddfe
b999fff
49f5c41
aaa1f35
90da2a0
88685c7
976954b
245edb3
a234df5
34d215f
1eb7528
a2e118e
732a62f
9375848
7504d30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…with a decoder
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,23 +1,89 @@ | ||||||
| // Licensed to the .NET Foundation under one or more agreements. | ||||||
| // The .NET Foundation licenses this file to you under the MIT license. | ||||||
|
|
||||||
| using System.Diagnostics; | ||||||
| using System.IO; | ||||||
| using System.Runtime.InteropServices; | ||||||
| using System.Text; | ||||||
|
|
||||||
| namespace System | ||||||
| { | ||||||
| internal sealed class NSLogStream : ConsoleStream | ||||||
| { | ||||||
| public NSLogStream() : base(FileAccess.Write) {} | ||||||
| private readonly StringBuilder _buffer = new StringBuilder(); | ||||||
| private Decoder _decoder; | ||||||
|
||||||
| private Decoder _decoder; | |
| private readonly Decoder _decoder; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this array be pooled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please clarify a bit with an example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every time this method is called, it is allocating a new array just to use as a scratch pad, and then thrown away. If we pool the array instead, we don't need to allocate a new array every time.
Here's an example:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
MaximLipnin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
steveisok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if you can use the StringBuilder.GetChunks() method instead of allocating a new string here. You should be able to enumerate through the "chunks" of the StringBuilder, and write them to Interop.Sys.Log without allocating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String builder can contain more than 1 chunk so enumerating though and writing them to Interop.Sys.Log means invoking NSLog several times, which would result in the same situation as right now because NSLog automatically appends a new line to any input.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method names should be PascalCased. And should be verbs.
| static void printer(string line) | |
| static void Print(string line) |
MaximLipnin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.