nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [RFC] Improving convert_sequence


From: Marco Diego Aurélio Mesquita
Subject: [Nano-devel] [RFC] Improving convert_sequence
Date: Fri, 20 Jul 2018 17:01:03 -0300

Hi Devs!

After having to dealt with the convert_sequence function (around 500
loc) I thought it could be improved. The idea I I had was to replace
it by something that could lookup escape sequences on a table.

I needed to get a list of escape sequences that nano recognizes and
turn it into a table. Since turning convert_sequence into a table
would be too much work, I opted for a brute force approach: test all 5
symbols combinations from a predefined alphabet and throw it at
convert_sequence to get its return. The change is on the attached
patch. After running it, a table around 600MB is generated, but after
filtering it with sort and uniq, I get a table with 164 entries! Table
log_filtered is attached for checking. That means nano recognizes 164
escape sequences and convert_sequence can be replaced by a small and
simple function that simply checks a 164 entries table.

Of course, the table I created can still be improved. Namely, hex
values can be replaced by more comprehensible macros. Also, we would
lose accumulated comments from long ago.

Anyway, Id think this is an improvement. it would allow us to drop
around 300 lines of code, the performance penalty is negligible (I
think) and adding new escape sequences would be easier. So, if someone
else agrees with me, I'd happy to improve convert_sequence.

Attachment: brute-force.patch
Description: Text Data

Attachment: log_filtered
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]