diff options
| author | Junio C Hamano <gitster@pobox.com> | 2018-08-02 15:30:43 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2018-08-02 15:30:43 -0700 |
| commit | ae533c4a92aef6ab180441dbb76ef83521fc87d6 (patch) | |
| tree | 0e722c62f6fb4a7d053bdb9bcb37115d8946336b /builtin/checkout.c | |
| parent | 30bf8d9f4f06d8e35793612c8611cb03c53a73db (diff) | |
| parent | 8616a2d0cb57865540f1c00ac2e5385a6cc5d84e (diff) | |
| download | git-ae533c4a92aef6ab180441dbb76ef83521fc87d6.tar.xz | |
Merge branch 'jm/cache-entry-from-mem-pool'
For a large tree, the index needs to hold many cache entries
allocated on heap. These cache entries are now allocated out of a
dedicated memory pool to amortize malloc(3) overhead.
* jm/cache-entry-from-mem-pool:
block alloc: add validations around cache_entry lifecyle
block alloc: allocate cache entries from mem_pool
mem-pool: fill out functionality
mem-pool: add life cycle management functions
mem-pool: only search head block for available space
block alloc: add lifecycle APIs for cache_entry structs
read-cache: teach make_cache_entry to take object_id
read-cache: teach refresh_cache_entry to take istate
Diffstat (limited to 'builtin/checkout.c')
| -rw-r--r-- | builtin/checkout.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index 923b8cbd82..516136a23a 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -79,7 +79,7 @@ static int update_some(const struct object_id *oid, struct strbuf *base, return READ_TREE_RECURSIVE; len = base->len + strlen(pathname); - ce = xcalloc(1, cache_entry_size(len)); + ce = make_empty_cache_entry(&the_index, len); oidcpy(&ce->oid, oid); memcpy(ce->name, base->buf, base->len); memcpy(ce->name + base->len, pathname, len - base->len); @@ -98,7 +98,7 @@ static int update_some(const struct object_id *oid, struct strbuf *base, if (ce->ce_mode == old->ce_mode && !oidcmp(&ce->oid, &old->oid)) { old->ce_flags |= CE_UPDATE; - free(ce); + discard_cache_entry(ce); return 0; } } @@ -232,11 +232,11 @@ static int checkout_merged(int pos, const struct checkout *state) if (write_object_file(result_buf.ptr, result_buf.size, blob_type, &oid)) die(_("Unable to add merge result for '%s'"), path); free(result_buf.ptr); - ce = make_cache_entry(mode, oid.hash, path, 2, 0); + ce = make_transient_cache_entry(mode, &oid, path, 2); if (!ce) die(_("make_cache_entry failed for path '%s'"), path); status = checkout_entry(ce, state, NULL); - free(ce); + discard_cache_entry(ce); return status; } |
