tsoding / ded

Dramatic EDitor
MIT License
570 stars 76 forks source link

Simplify the lexer_starts_with function #62

Open RHL120 opened 1 year ago

BillKek commented 1 year ago

It became harder to understand.

RHL120 commented 1 year ago

It became harder to understand.

Hmm, maybe you are right but to me I can read it in simple english: if the prefix's length is zero or the the length of the rest of the string (after the cursor) is more than the prefix length and if the string starts with the prefix. If the string were NULL terminated the second condition could be removed but I checked and it does not seem to be. Plus the previous function implemented the libc function strncmp. Thanks for the review!