diff options
| author | Lars Ingebrigtsen | 2021-12-20 10:26:25 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-12-21 05:23:11 +0100 |
| commit | 4d8af56c76ee20bc8e1ebdeef5c4100cea005974 (patch) | |
| tree | 44eddef3b7e2e7176bf69fcf9c36626f42e1f72e /src | |
| parent | 0c4fc7032ab32fb639c188d9647eb132d55adfa5 (diff) | |
| download | emacs-4d8af56c76ee20bc8e1ebdeef5c4100cea005974.tar.gz emacs-4d8af56c76ee20bc8e1ebdeef5c4100cea005974.zip | |
Speed up find_field when called from outside a field
* src/editfns.c (find_field): Speed up the field functions when
called from outside a field (bug#52593). (In some cursory tests,
this makes the called-from-outside-a-field case about 3x faster.)
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/editfns.c b/src/editfns.c index 5c9c34dc352..355a7a3e299 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -437,6 +437,27 @@ find_field (Lisp_Object pos, Lisp_Object merge_at_boundary, | |||
| 437 | 437 | ||
| 438 | after_field | 438 | after_field |
| 439 | = get_char_property_and_overlay (pos, Qfield, Qnil, NULL); | 439 | = get_char_property_and_overlay (pos, Qfield, Qnil, NULL); |
| 440 | |||
| 441 | /* We're not in a field, so find the prev/next area with a field | ||
| 442 | property. */ | ||
| 443 | if (NILP (after_field)) | ||
| 444 | { | ||
| 445 | if (beg) | ||
| 446 | { | ||
| 447 | Lisp_Object p = Fprevious_single_char_property_change (pos, Qfield, | ||
| 448 | Qnil, | ||
| 449 | beg_limit); | ||
| 450 | *beg = NILP (p) ? BEGV : XFIXNAT (p); | ||
| 451 | } | ||
| 452 | if (end) | ||
| 453 | { | ||
| 454 | Lisp_Object p = Fnext_single_char_property_change (pos, Qfield, Qnil, | ||
| 455 | end_limit); | ||
| 456 | *end = NILP (p) ? ZV : XFIXNAT (p); | ||
| 457 | } | ||
| 458 | return; | ||
| 459 | } | ||
| 460 | |||
| 440 | before_field | 461 | before_field |
| 441 | = (XFIXNAT (pos) > BEGV | 462 | = (XFIXNAT (pos) > BEGV |
| 442 | ? get_char_property_and_overlay (make_fixnum (XFIXNUM (pos) - 1), | 463 | ? get_char_property_and_overlay (make_fixnum (XFIXNUM (pos) - 1), |