mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-08-18 15:26:05 +00:00
Add LG_BLOCKSIZE to omit some *, % ops
* src/buffer.c (_flush_write, short_read, seek_archive) (_gnu_flush_write): * src/create.c (write_gnu_long_link, dump_regular_file) (dump_dir0): * src/delete.c (write_recent_bytes, flush_file) (delete_archive_members): * src/list.c (read_header): * src/sparse.c (sparse_dump_region, sparse_extract_region) (pax_dump_header_1): * src/tar.c (parse_opt): * src/update.c (append_file): Prefer shifting and masking to dividing and remaindering by BLOCKSIZE. This reclaims some compiler optimizations lost by our recent preference for signed integers. * src/tar.h (LG_BLOCKSIZE): New constant, for shifting.
This commit is contained in:
+5
-4
@@ -114,8 +114,8 @@ write_recent_blocks (union block *h, idx_t blocks)
|
||||
static void
|
||||
write_recent_bytes (char *data, idx_t bytes)
|
||||
{
|
||||
idx_t blocks = bytes / BLOCKSIZE;
|
||||
idx_t rest = bytes % BLOCKSIZE;
|
||||
idx_t blocks = bytes >> LG_BLOCKSIZE;
|
||||
idx_t rest = bytes & (BLOCKSIZE - 1);
|
||||
|
||||
write_recent_blocks ((union block *)data, blocks);
|
||||
memcpy (new_record[new_blocks].buffer, data + blocks * BLOCKSIZE, rest);
|
||||
@@ -131,7 +131,7 @@ flush_file (void)
|
||||
{
|
||||
set_next_block_after (current_header);
|
||||
off_t size = current_stat_info.stat.st_size;
|
||||
off_t blocks_to_skip = size / BLOCKSIZE + (size % BLOCKSIZE != 0);
|
||||
off_t blocks_to_skip = (size >> LG_BLOCKSIZE) + !!(size & (BLOCKSIZE - 1));
|
||||
|
||||
while (record_end - current_block <= blocks_to_skip)
|
||||
{
|
||||
@@ -293,7 +293,8 @@ delete_archive_members (void)
|
||||
new_record[new_blocks] = *current_header;
|
||||
new_blocks++;
|
||||
blocks_to_keep
|
||||
= (current_stat_info.stat.st_size + BLOCKSIZE - 1) / BLOCKSIZE;
|
||||
= ((current_stat_info.stat.st_size >> LG_BLOCKSIZE)
|
||||
+ !!(current_stat_info.stat.st_size & (BLOCKSIZE - 1)));
|
||||
set_next_block_after (current_header);
|
||||
if (new_blocks == blocking_factor)
|
||||
write_record (true);
|
||||
|
||||
Reference in New Issue
Block a user