Mercurial > vim
comparison src/xxd/xxd.c @ 26000:16aaed83522a v8.2.3533
patch 8.2.3533: inefficient code in xxd
Commit: https://github.com/vim/vim/commit/375c35a63fdb91e8db2a9965f94d56ae87135fff
Author: DungSaga <dungsaga@users.noreply.github.com>
Date: Mon Oct 18 13:16:03 2021 +0100
patch 8.2.3533: inefficient code in xxd
Problem: Inefficient code in xxd.
Solution: Don't use "p" when "hextype" is non-zero. (closes https://github.com/vim/vim/issues/9013)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 18 Oct 2021 14:30:06 +0200 |
parents | 2294ed638906 |
children | c8165ec9dcad |
comparison
equal
deleted
inserted
replaced
25999:5080aec1406b | 26000:16aaed83522a |
---|---|
300 continue; | 300 continue; |
301 } | 301 } |
302 | 302 |
303 ign_garb = 0; | 303 ign_garb = 0; |
304 | 304 |
305 if (p >= cols) | 305 if (!hextype && (p >= cols)) |
306 { | 306 { |
307 if (!hextype) | 307 if (n1 < 0) |
308 { | 308 { |
309 if (n1 < 0) | 309 p = 0; |
310 { | |
311 p = 0; | |
312 continue; | |
313 } | |
314 want_off = (want_off << 4) | n1; | |
315 continue; | 310 continue; |
316 } | 311 } |
317 else | 312 want_off = (want_off << 4) | n1; |
318 p = 0; | 313 continue; |
319 } | 314 } |
320 | 315 |
321 if (base_off + want_off != have_off) | 316 if (base_off + want_off != have_off) |
322 { | 317 { |
323 if (fflush(fpo) != 0) | 318 if (fflush(fpo) != 0) |
342 if (putc((n2 << 4) | n1, fpo) == EOF) | 337 if (putc((n2 << 4) | n1, fpo) == EOF) |
343 die(3); | 338 die(3); |
344 have_off++; | 339 have_off++; |
345 want_off++; | 340 want_off++; |
346 n1 = -1; | 341 n1 = -1; |
347 if ((++p >= cols) && !hextype) | 342 if (!hextype && (++p >= cols)) |
348 { | 343 { |
349 /* skip the rest of the line as garbage */ | 344 /* skip the rest of the line as garbage */ |
350 n2 = -1; | 345 n2 = -1; |
351 n3 = -1; | 346 n3 = -1; |
352 } | 347 } |