id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	branch_state	votes
4421	mcedit is slow at handling files with long lines (25KB+)	slyfox		"Initially noticed '''mcedit''' slowness when I attempted to insert with '''Shift+Insert''' a single 35KB-long line from clipboard. It took about 40 seconds to insert that tiny amount of data.

The same slowness is visible if I open mcedit in a file with long line and start adding individual symbols to the end of it (say, press down an 'a' key and rely on repeat): CPU usage grows to 100%. '''perf top''' says most of the time is spent traversing some buffers:

{{{
  26,69%  mc                      [.] edit_buffer_get_utf
  25,02%  mc                      [.] edit_move_forward3
  14,99%  mc                      [.] edit_buffer_get_byte
   9,16%  libglib-2.0.so.0.7400.3 [.] g_utf8_get_char_validated
   5,51%  libglib-2.0.so.0.7400.3 [.] g_unichar_iswide
   4,33%  mc                      [.] edit_buffer_get_bol
   1,88%  mc                      [.] g_utf8_get_char_validated@plt
}}}

It looks like appending each next char requires traversal of the line. Looks like it causes quadratic behaviour when we insert large chunks of text via clipbuffer.

{{{
$ LANG=C mc --version
GNU Midnight Commander 4.8.28
Built with GLib 2.74.3
Built with S-Lang 2.3.3 with terminfo database
Built with libssh2 1.10.0
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm and Linux console
With support for X11 events
With internationalization support
With multiple codepages support
With ext2fs attributes support
Virtual File Systems:
 cpiofs, tarfs, sfs, extfs, ftpfs, sftpfs, fish
Data types:
 char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;
}}}"	defect	new	major	Future Releases	mcedit	4.8.28						no branch	
