|
16 | 16 | #define FAST_WORKING_DIRECTORY 1
|
17 | 17 | #endif
|
18 | 18 |
|
19 |
| -static int use_size_cache; |
20 |
| - |
21 | 19 | static int diff_detect_rename_default;
|
22 | 20 | static int diff_rename_limit_default = -1;
|
23 | 21 | static int diff_use_color_default;
|
@@ -1408,55 +1406,6 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
|
1408 | 1406 | return 1;
|
1409 | 1407 | }
|
1410 | 1408 |
|
1411 |
| -static struct sha1_size_cache { |
1412 |
| - unsigned char sha1[20]; |
1413 |
| - unsigned long size; |
1414 |
| -} **sha1_size_cache; |
1415 |
| -static int sha1_size_cache_nr, sha1_size_cache_alloc; |
1416 |
| - |
1417 |
| -static struct sha1_size_cache *locate_size_cache(unsigned char *sha1, |
1418 |
| - int find_only, |
1419 |
| - unsigned long size) |
1420 |
| -{ |
1421 |
| - int first, last; |
1422 |
| - struct sha1_size_cache *e; |
1423 |
| - |
1424 |
| - first = 0; |
1425 |
| - last = sha1_size_cache_nr; |
1426 |
| - while (last > first) { |
1427 |
| - int cmp, next = (last + first) >> 1; |
1428 |
| - e = sha1_size_cache[next]; |
1429 |
| - cmp = hashcmp(e->sha1, sha1); |
1430 |
| - if (!cmp) |
1431 |
| - return e; |
1432 |
| - if (cmp < 0) { |
1433 |
| - last = next; |
1434 |
| - continue; |
1435 |
| - } |
1436 |
| - first = next+1; |
1437 |
| - } |
1438 |
| - /* not found */ |
1439 |
| - if (find_only) |
1440 |
| - return NULL; |
1441 |
| - /* insert to make it at "first" */ |
1442 |
| - if (sha1_size_cache_alloc <= sha1_size_cache_nr) { |
1443 |
| - sha1_size_cache_alloc = alloc_nr(sha1_size_cache_alloc); |
1444 |
| - sha1_size_cache = xrealloc(sha1_size_cache, |
1445 |
| - sha1_size_cache_alloc * |
1446 |
| - sizeof(*sha1_size_cache)); |
1447 |
| - } |
1448 |
| - sha1_size_cache_nr++; |
1449 |
| - if (first < sha1_size_cache_nr) |
1450 |
| - memmove(sha1_size_cache + first + 1, sha1_size_cache + first, |
1451 |
| - (sha1_size_cache_nr - first - 1) * |
1452 |
| - sizeof(*sha1_size_cache)); |
1453 |
| - e = xmalloc(sizeof(struct sha1_size_cache)); |
1454 |
| - sha1_size_cache[first] = e; |
1455 |
| - hashcpy(e->sha1, sha1); |
1456 |
| - e->size = size; |
1457 |
| - return e; |
1458 |
| -} |
1459 |
| - |
1460 | 1409 | static int populate_from_stdin(struct diff_filespec *s)
|
1461 | 1410 | {
|
1462 | 1411 | #define INCREMENT 1024
|
@@ -1512,12 +1461,12 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
|
1512 | 1461 | if (S_ISDIR(s->mode))
|
1513 | 1462 | return -1;
|
1514 | 1463 |
|
1515 |
| - if (!use_size_cache) |
1516 |
| - size_only = 0; |
1517 |
| - |
1518 | 1464 | if (s->data)
|
1519 | 1465 | return 0;
|
1520 | 1466 |
|
| 1467 | + if (size_only && 0 < s->size) |
| 1468 | + return 0; |
| 1469 | + |
1521 | 1470 | if (S_ISDIRLNK(s->mode))
|
1522 | 1471 | return diff_populate_gitlink(s, size_only);
|
1523 | 1472 |
|
@@ -1579,19 +1528,8 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
|
1579 | 1528 | }
|
1580 | 1529 | else {
|
1581 | 1530 | enum object_type type;
|
1582 |
| - struct sha1_size_cache *e; |
1583 |
| - |
1584 |
| - if (size_only && use_size_cache && |
1585 |
| - (e = locate_size_cache(s->sha1, 1, 0)) != NULL) { |
1586 |
| - s->size = e->size; |
1587 |
| - return 0; |
1588 |
| - } |
1589 |
| - |
1590 |
| - if (size_only) { |
| 1531 | + if (size_only) |
1591 | 1532 | type = sha1_object_info(s->sha1, &s->size);
|
1592 |
| - if (use_size_cache && 0 < type) |
1593 |
| - locate_size_cache(s->sha1, 0, s->size); |
1594 |
| - } |
1595 | 1533 | else {
|
1596 | 1534 | s->data = read_sha1_file(s->sha1, &type, &s->size);
|
1597 | 1535 | s->should_free = 1;
|
@@ -2102,8 +2040,6 @@ int diff_setup_done(struct diff_options *options)
|
2102 | 2040 | */
|
2103 | 2041 | read_cache();
|
2104 | 2042 | }
|
2105 |
| - if (options->setup & DIFF_SETUP_USE_SIZE_CACHE) |
2106 |
| - use_size_cache = 1; |
2107 | 2043 | if (options->abbrev <= 0 || 40 < options->abbrev)
|
2108 | 2044 | options->abbrev = 40; /* full */
|
2109 | 2045 |
|
|
0 commit comments