Commit Graph

254 Commits (15e36956b5ee2b87fee2b2a2651704641b60399f)

Author SHA1 Message Date
Benno Schulenberg 15e36956b5 tweaks: avoid parsing a character twice
Let mbtowc() do all the work, and thus also elide a variable.
2019-06-10 12:01:10 +02:00
Benno Schulenberg 967f581860 tweaks: adjust some whitespace and rewrap a few lines
And remove two unneeded casts.
2019-06-09 20:03:44 +02:00
Benno Schulenberg 1075de1222 tweaks: rename two functions, to get rid of the "mb" abbreviation
Also, for me "move" is about moving the cursor.  But these functions
are about moving an index in a text, which is more general.
2019-06-09 19:37:56 +02:00
Benno Schulenberg 710a600f22 chars: speed up case-insensitive searching by roughly one percent
It is less of a speedup than I was hoping for, though.
2019-06-09 19:13:25 +02:00
Benno Schulenberg 781c7a7a5f chars: create a dedicated function for getting the length of a character
Instead of calling in twenty places parse_mbchar(pointer, NULL, NULL),
use a simpler and faster char_length(pointer).  This saves pushing two
unneeded parameters onto the stack, avoids two needless ifs, and elides
an intermediate variable.

Its main purpose will follow in a later commit: to speed up searching.
2019-06-09 18:38:46 +02:00
Benno Schulenberg aa205f58ca tweaks: rename a bunch of variables, to become identical to others 2019-06-09 17:07:02 +02:00
Benno Schulenberg 71236e145d tweaks: rename two variables, away from a single letter
And adjust the indentation after the previous change.
2019-06-09 11:08:34 +02:00
Benno Schulenberg 7be76af418 tweaks: speed up the counting of characters in mbstrlen()
This function is used in get_totsize(), so speed is important.

There is no reason why the length of the string must limited to a
certain size -- that is just a leftover from the function merge in
commit ba2e6f43 from a year ago.
2019-06-09 11:04:52 +02:00
Benno Schulenberg fb17929fab tweaks: use FALSE for booleans instead of zero
Also adjust some indentation and reduce the scope of a variable.
2019-06-09 10:41:14 +02:00
Benno Schulenberg 55952c0984 tweaks: adjust the indentation after the previous change
Also, improve a comment and shorten another, change a 'for' to a 'while'
(as the end point is not known), and rename a parameter from a single
letter to a word.
2019-04-06 19:45:45 +02:00
Benno Schulenberg d9cfdd364b tweaks: don't bother special-casing non-UTF8 when seeking a character
This code is seldom used (only when searching for a matching bracket),
so speed is not a priority.
2019-04-06 19:34:09 +02:00
Benno Schulenberg e02c8aeb20 tweaks: adjust indentation after previous change, and rename a parameter 2019-03-24 09:42:57 +01:00
Benno Schulenberg 003ddc763e tweaks: don't bother special-casing non-UTF8 when checking for a blank
This code is almost never used; conciseness is the only consideration.
2019-03-24 09:36:15 +01:00
Benno Schulenberg 1c3953705c tweaks: avoid parsing the same character twice
Also, make the second loop similar in form to the first.
2019-03-24 09:34:21 +01:00
Benno Schulenberg 01e6d435fe tweaks: rename a function, to be simpler and more accurate 2019-03-21 17:42:34 +01:00
Benno Schulenberg 2b21d53857 tweaks: elide a function that is called just once 2019-03-21 17:36:46 +01:00
Benno Schulenberg a20340b5a8 copyright: update the years for significantly changed files 2019-03-10 17:03:42 +01:00
Benno Schulenberg 79ca3ceabf copyright: update the years for the FSF 2019-02-24 19:35:56 +01:00
Benno Schulenberg ce0ecf67a6 tweaks: elide another function that is used just once 2018-07-10 13:57:05 +02:00
Benno Schulenberg b6f7ff5c6f tweaks: normalize the indentation after the previous change
And remove two superfluous pairs of braces.
2018-07-10 13:55:51 +02:00
Benno Schulenberg 035b91cb15 chars: make the UTF-8 case ever so slightly faster by eliding an 'if'
And in the bargain get rid of some duplicate code.

This makes a binary without UTF-8 support slightly slower, but that's
not important -- it is more than fast enough anyway.  Important is that
the most used and longest code path, the UTF-8 case, becomes faster.

Note that 'is_cntrl_mbchar()' will fall back to 'is_cntrl_char()' for
a non-UTF-8 build, so the deleted piece of code really was equivalent
with the remaining piece for that case.
2018-07-10 12:22:11 +02:00
Benno Schulenberg 7ae8f3bca4 tweaks: elide a function that is used just once 2018-07-08 10:40:22 +02:00
Benno Schulenberg 9a7ba5db79 chars: speed up the parsing of a character for the plain ASCII case
Again, if the most significant bit of a UTF-8 byte is zero, it means
the character is a single byte and we can skip the call of mblen(),
*and* if the character is one byte it also occupies just one column,
because all ASCII characters are single-column characters -- apart
from control codes.

This partially addresses https://savannah.gnu.org/bugs/?51491.
2018-06-04 14:07:43 +02:00
Benno Schulenberg cc2b19c8fd chars: speed up the counting of string length for the plain ASCII case
For UTF-8, if the most significant bit of a byte is zero, it means the
character is just a single byte and we can skip the call of mblen().

For files consisting of pure ASCII bytes (between 0x00 and 0x7F), this
change reduces the counting time of mbstrlen() by ninety six percent.

This partially addresses https://savannah.gnu.org/bugs/?50406.
2018-06-03 20:07:04 +02:00
Benno Schulenberg 4e667bd048 tweaks: reduce the counting of characters to just the needed function
Evade the indirect use of the general-purpose function parse_mbchar().
This reduces the counting time by roughly ten percent.
2018-06-03 17:58:05 +02:00
Benno Schulenberg ba2e6f43c2 tweaks: elide a subfunction that is used just once
(Forgot to say: the previous two commits addressed
https://savannah.gnu.org/bugs/?54044.)
2018-06-03 17:47:02 +02:00
Benno Schulenberg 6c555828c9 tweaks: remove redundant braces and conditions after the previous change 2018-06-03 14:13:33 +02:00
Benno Schulenberg 0ff068380c tweaks: remove the superfluous calls that reset the mbtowc() state
When mbtowc() is never called with anything less than MAXCHARLEN as
the length parameter, it will apparently not get confused and will
not need to be reset.
2018-06-03 14:06:59 +02:00
Benno Schulenberg f72fecee9b copyright: update the years for the FSF
And one for me, for the much changed keyboard stuff.
2018-01-24 10:14:43 +01:00
Benno Schulenberg 17429d7f38 tweaks: fix some whitespace errors, and convert alignment tabs to spaces 2017-12-29 21:35:14 +01:00
Benno Schulenberg 87206c0607 tweaks: convert the indentation to use only tabs
Each leading tab is converted to two tabs, and any leading four spaces
is converted to one tab.  The intended tab size (for keeping most lines
within 80 columns) is now four.
2017-12-29 20:06:50 +01:00
Benno Schulenberg 5198c1f139 tweaks: frob a couple of comments 2017-11-12 20:08:28 +01:00
Benno Schulenberg 5239e7c52b copyright: update some years, and standardize on the dashed format 2017-11-12 10:46:20 +01:00
Benno Schulenberg db0b849f9b tweaks: transform the token DISABLE_JUSTIFY to ENABLE_JUSTIFY 2017-10-31 17:40:44 +01:00
Benno Schulenberg 11072ed587 tweaks: sort the includes, so it's a little easier to see what is there 2017-08-06 19:40:30 +02:00
Benno Schulenberg 858e75e4cf tweaks: transform the token DISABLE_NANORC to ENABLE_NANORC
Also, allow rebinding the word and block jumping functions
in the tiny version when nanorc files are reenabled.
2017-05-09 11:59:34 +02:00
David Lawrence Ramsey 03c3e2b7c0 tweaks: fix several whitespace irregularities
Add missing spaces, remove excess spaces, and
replace groups of indentation spaces with tabs.
2017-05-07 18:20:01 +02:00
Benno Schulenberg f5155786e1 tweaks: adjust whitespace and comments after the preceding change 2017-05-05 21:54:23 +02:00
Benno Schulenberg a9abc3d95f chars: optimize moving a character left in the non-UTF-8 case
When not in a UTF-8 locale, each character is just a single byte.
2017-05-05 21:40:00 +02:00
Benno Schulenberg 09cabcad5d chars: probe for a valid UTF-8 starter byte, instead of overstepping
Instead of always stepping back four bytes and then tentatively
moving forward again (which is wasteful when most codes are just
one or two bytes long), inspect the preceding bytes one by one
and begin the move forward at the first valid starter byte.

This reduces the backwards searching time by close to 40 percent.
2017-05-05 21:36:45 +02:00
Benno Schulenberg f162a6a2ab chars: valid UTF-8 codes are at most 4 bytes long, so look only that far
This reduces the backwards searching time by a good 20 percent.
2017-05-05 21:34:23 +02:00
Benno Schulenberg c42d6d378a tweaks: check for an empty needle in a central place
Searching for an empty string should be impossible, it should never
happen, but it is bit too hard to verify this at the moment.
2017-04-30 20:32:01 +02:00
Benno Schulenberg 1a79b3d514 tweaks: remove a superfluous strlen() call from the reverse searches
If the length of the haystack is smaller than the length of the needle,
this means that also the length of the tail will be smaller -- because
pointer will be bigger than or equal to haystack -- so the pointer gets
readjusted to be a needle length before the end of the haystack, which
means that it ends up /before/ the haystack: thus the while loop will
never run.

On average, this saves some 200 nanoseconds per line.
2017-04-30 19:51:36 +02:00
Benno Schulenberg 7d3d3dec9a tweaks: use the logic from revstrstr() also in mbrevstrcasestr()
Because it is slightly faster.
2017-04-30 19:51:14 +02:00
Benno Schulenberg 6240805c41 tweaks: rename one variable again
It is not an index, it is not an offset from anything,
it is a direct pointer.
2017-04-30 17:50:12 +02:00
Benno Schulenberg 6967fae35d tweaks: use the logic from revstrstr() also in revstrcasestr()
This elides a counter and a comparison from the central loop,
and thus makes the search a tiny bit faster.
2017-04-28 22:12:53 +02:00
Benno Schulenberg a37435141a tweaks: rename some more of these 'rev_start' variables 2017-04-28 22:09:38 +02:00
Benno Schulenberg 329021e24a tweaks: rename two variables, because this 'rev_start' is irksome
And one-letter variables I cannot "see" -- they are too small.
2017-04-28 21:02:24 +02:00
Benno Schulenberg b06407fbd7 tweaks: drop a bunch of asserts 2017-04-28 16:07:27 +02:00
Benno Schulenberg 754c62c5cc copyright: update the years, use ranges, and explain this usage
The interval 2013-2017 for the Free Software Foundation is valid
because in those years there were releases with changes by either
Chris or David, and the GNU maintainers guide advises to mention
a new year in all files of a package, not just in the ones that
actually changed, and be done with it for the rest of the year.
2017-04-09 12:09:23 +02:00