phobos src level stats
Bruce Carneal
bcarneal at gmail.com
Wed Sep 23 00:48:16 UTC 2020
On Tuesday, 22 September 2020 at 23:22:42 UTC, DlangUser38 wrote:
> On Tuesday, 22 September 2020 at 21:01:17 UTC, Bruce Carneal
> wrote:
>> The empty line numbers seem a little high to me. I may have a
>> bug in the code for that:
>>
>> ulong countEmptyLines(string rawText) @nogc nothrow pure @safe
>> {
>> ulong empties;
>> lineLoop: foreach (line; lineSplitter(rawText))
>> {
>> foreach_reverse (ch; line)
>> if (ch != ' ' && ch != '\t')
>> continue lineLoop;
>> ++empties;
>> }
>> return empties;
>> }
>
> you can count empty lines using a sliding window of two token
> over the token range.
> The difference between the two token position give empty line.
> string literal and comments require a special processing but
> otherwise this is quite straightforward to implement.
So, a way to stay in "token space" then. Don't see a problem
with the above but will note for future apps that I need not drop
back to raw text.
More information about the Digitalmars-d
mailing list