On Mon, 11 Oct 2021 at 15:12, Omar Polo <op@omarpolo.com> wrote: > I've seen this argument in the gitlab issue too […] I haven't checked the issue yet, will do after sending this. > In what language(s) splitting a string is faster than > checking for a prefix? Splitting requires the allocation of multiple > objects, while the prefix only requires a scan of the first few bytes. I said simpler, not faster. What you said is true in some cases, but not everyone is striving for optimisation speed-wise. It'll depend on the language used, but splitting allows you to use a simple equality switch statement, which isn't possible by checking with a prefix. The way I understand your message, I would have to use an else-if list, which is hardly ideal. e.g. in C#: ``` // If it's <3 chars then just treat it as a text line (the default). switch ((line.Length < 3) ? "" : line.Substring(0, 3).Split(" ", 2)[0]) { case "=>": … case "* ": … … and so on … default: … } ``` vs ``` if (line.StartsWith("=> ") { … } else if (line.StartsWith("* ") { … } … and so on … else { … } ``` At the least, it should be required for link (as you said) and list lines ("* "). I've seen where people have tried to use *emphasis* at the start of a line and got a bullet point by mistake. > > I see no downside to enforcing it in the spec (a SHOULD or MUST). > > My argument is kind the opposite: if there isn't a (strong) reason for > requiring something, then that something MUST be optional. Whitespaces > are required in the link line to separate unambiguously the link from > the label, the other whitespaces in the "special" lines don't serve this > purpose so they need to be completely optional. At the very least it should be recommended by the spec IMO. -Oliver Simmons (GoodClover)
---
Previous in thread (11 of 50): 🗣️ Robert "khuxkm" Miles (khuxkm (a) tilde.team)
Next in thread (13 of 50): 🗣️ Oliver Simmons (oliversimmo (a) gmail.com)