diff options
| author | Mattias EngdegÄrd | 2020-04-03 16:01:01 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2020-04-05 15:37:55 +0200 |
| commit | 4ed39549e3f9dbfeb2aea0e2674a7701dbc0e5ea (patch) | |
| tree | 192e8b852c9af4e70ee3ec7a7ca26ae82c57bb2c /test | |
| parent | c7ac76603f291d432586abd2eeb75e1ca6e54863 (diff) | |
| download | emacs-4ed39549e3f9dbfeb2aea0e2674a7701dbc0e5ea.tar.gz emacs-4ed39549e3f9dbfeb2aea0e2674a7701dbc0e5ea.zip | |
Avoid expensive recoding for ASCII identity cases (bug#40407)
Optimise for the common case of encoding or decoding an ASCII-only
string using an ASCII-compatible coding, for file names in particular.
* src/coding.c (string_ascii_p): New function.
(code_convert_string): Return the input string for ASCII-only inputs
and ASCII-compatible codings.
* test/src/coding-tests.el (coding-nocopy-ascii): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/src/coding-tests.el | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/src/coding-tests.el b/test/src/coding-tests.el index 110ff126964..93e6709d442 100644 --- a/test/src/coding-tests.el +++ b/test/src/coding-tests.el | |||
| @@ -383,6 +383,17 @@ | |||
| 383 | (should-not (eq (encode-coding-string s nil nil) s)) | 383 | (should-not (eq (encode-coding-string s nil nil) s)) |
| 384 | (should (eq (encode-coding-string s nil t) s)))) | 384 | (should (eq (encode-coding-string s nil t) s)))) |
| 385 | 385 | ||
| 386 | (ert-deftest coding-nocopy-ascii () | ||
| 387 | "Check that the NOCOPY parameter works for ASCII-only strings." | ||
| 388 | (let* ((uni (apply #'string (number-sequence 0 127))) | ||
| 389 | (multi (string-to-multibyte uni))) | ||
| 390 | (dolist (s (list uni multi)) | ||
| 391 | (dolist (coding '(us-ascii iso-latin-1 utf-8)) | ||
| 392 | (should-not (eq (decode-coding-string s coding nil) s)) | ||
| 393 | (should-not (eq (encode-coding-string s coding nil) s)) | ||
| 394 | (should (eq (decode-coding-string s coding t) s)) | ||
| 395 | (should (eq (encode-coding-string s coding t) s)))))) | ||
| 396 | |||
| 386 | ;; Local Variables: | 397 | ;; Local Variables: |
| 387 | ;; byte-compile-warnings: (not obsolete) | 398 | ;; byte-compile-warnings: (not obsolete) |
| 388 | ;; End: | 399 | ;; End: |