Created
January 21, 2020 01:49
-
-
Save hyrmn/17289a5454ff28bfd084643c80ba3f6c to your computer and use it in GitHub Desktop.
netcore 3.1. hardcoded to the location of a 1.6gb text file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var count = 0; | |
using var reader = File.OpenText(@"C:\code\go\src\github.com\hyrmn\lc\pkg\lc\testdata\bigsum.txt"); | |
var buffer = new Span<char>(new char[1024]); | |
int readLength; | |
while ((readLength = reader.Read(buffer)) != 0) | |
{ | |
var position = 0; | |
while(true) | |
{ | |
var slice = buffer.Slice(position, readLength - position); | |
var idxOf = slice.IndexOf('\n'); | |
if (idxOf == -1) | |
{ | |
break; | |
} | |
count++; | |
position += idxOf + 1; | |
} | |
} | |
Console.WriteLine(count); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment