Commit 46bb0067 by Carlos Martín Nieto

tree-cache: remove the parent pointer

This wasn't used. We invalidate based on the full path, so we always go
down the tree, never up.
parent ee4db1c1
...@@ -72,7 +72,7 @@ const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char ...@@ -72,7 +72,7 @@ const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char
static int read_tree_internal(git_tree_cache **out, static int read_tree_internal(git_tree_cache **out,
const char **buffer_in, const char *buffer_end, const char **buffer_in, const char *buffer_end,
git_tree_cache *parent, git_pool *pool) git_pool *pool)
{ {
git_tree_cache *tree = NULL; git_tree_cache *tree = NULL;
const char *name_start, *buffer; const char *name_start, *buffer;
...@@ -86,7 +86,7 @@ static int read_tree_internal(git_tree_cache **out, ...@@ -86,7 +86,7 @@ static int read_tree_internal(git_tree_cache **out,
if (++buffer >= buffer_end) if (++buffer >= buffer_end)
goto corrupted; goto corrupted;
if (git_tree_cache_new(&tree, name_start, parent, pool) < 0) if (git_tree_cache_new(&tree, name_start, pool) < 0)
return -1; return -1;
/* Blank-terminated ASCII decimal number of entries in this tree */ /* Blank-terminated ASCII decimal number of entries in this tree */
...@@ -127,7 +127,7 @@ static int read_tree_internal(git_tree_cache **out, ...@@ -127,7 +127,7 @@ static int read_tree_internal(git_tree_cache **out,
memset(tree->children, 0x0, tree->children_count * sizeof(git_tree_cache *)); memset(tree->children, 0x0, tree->children_count * sizeof(git_tree_cache *));
for (i = 0; i < tree->children_count; ++i) { for (i = 0; i < tree->children_count; ++i) {
if (read_tree_internal(&tree->children[i], &buffer, buffer_end, tree, pool) < 0) if (read_tree_internal(&tree->children[i], &buffer, buffer_end, pool) < 0)
goto corrupted; goto corrupted;
} }
} }
...@@ -145,7 +145,7 @@ int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer ...@@ -145,7 +145,7 @@ int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer
{ {
const char *buffer_end = buffer + buffer_size; const char *buffer_end = buffer + buffer_size;
if (read_tree_internal(tree, &buffer, buffer_end, NULL, pool) < 0) if (read_tree_internal(tree, &buffer, buffer_end, pool) < 0)
return -1; return -1;
if (buffer < buffer_end) { if (buffer < buffer_end) {
...@@ -194,7 +194,7 @@ static int read_tree_recursive(git_tree_cache *cache, const git_tree *tree, git_ ...@@ -194,7 +194,7 @@ static int read_tree_recursive(git_tree_cache *cache, const git_tree *tree, git_
if (git_tree_entry_filemode(entry) != GIT_FILEMODE_TREE) if (git_tree_entry_filemode(entry) != GIT_FILEMODE_TREE)
continue; continue;
if ((error = git_tree_cache_new(&cache->children[j], git_tree_entry_name(entry), cache, pool)) < 0) if ((error = git_tree_cache_new(&cache->children[j], git_tree_entry_name(entry), pool)) < 0)
return error; return error;
if ((error = git_tree_lookup(&subtree, repo, git_tree_entry_id(entry))) < 0) if ((error = git_tree_lookup(&subtree, repo, git_tree_entry_id(entry))) < 0)
...@@ -216,7 +216,7 @@ int git_tree_cache_read_tree(git_tree_cache **out, const git_tree *tree, git_poo ...@@ -216,7 +216,7 @@ int git_tree_cache_read_tree(git_tree_cache **out, const git_tree *tree, git_poo
int error; int error;
git_tree_cache *cache; git_tree_cache *cache;
if ((error = git_tree_cache_new(&cache, "", NULL, pool)) < 0) if ((error = git_tree_cache_new(&cache, "", pool)) < 0)
return error; return error;
if ((error = read_tree_recursive(cache, tree, pool)) < 0) if ((error = read_tree_recursive(cache, tree, pool)) < 0)
...@@ -226,7 +226,7 @@ int git_tree_cache_read_tree(git_tree_cache **out, const git_tree *tree, git_poo ...@@ -226,7 +226,7 @@ int git_tree_cache_read_tree(git_tree_cache **out, const git_tree *tree, git_poo
return 0; return 0;
} }
int git_tree_cache_new(git_tree_cache **out, const char *name, git_tree_cache *parent, git_pool *pool) int git_tree_cache_new(git_tree_cache **out, const char *name, git_pool *pool)
{ {
size_t name_len; size_t name_len;
git_tree_cache *tree; git_tree_cache *tree;
...@@ -236,7 +236,6 @@ int git_tree_cache_new(git_tree_cache **out, const char *name, git_tree_cache *p ...@@ -236,7 +236,6 @@ int git_tree_cache_new(git_tree_cache **out, const char *name, git_tree_cache *p
GITERR_CHECK_ALLOC(tree); GITERR_CHECK_ALLOC(tree);
memset(tree, 0x0, sizeof(git_tree_cache)); memset(tree, 0x0, sizeof(git_tree_cache));
tree->parent = parent;
/* NUL-terminated tree name */ /* NUL-terminated tree name */
tree->namelen = name_len; tree->namelen = name_len;
memcpy(tree->name, name, name_len); memcpy(tree->name, name, name_len);
......
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
#include "pool.h" #include "pool.h"
#include "git2/oid.h" #include "git2/oid.h"
typedef struct { typedef struct git_tree_cache {
struct git_tree_cache *parent;
struct git_tree_cache **children; struct git_tree_cache **children;
size_t children_count; size_t children_count;
...@@ -26,7 +25,7 @@ typedef struct { ...@@ -26,7 +25,7 @@ typedef struct {
int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer_size, git_pool *pool); int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer_size, git_pool *pool);
void git_tree_cache_invalidate_path(git_tree_cache *tree, const char *path); void git_tree_cache_invalidate_path(git_tree_cache *tree, const char *path);
const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char *path); const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char *path);
int git_tree_cache_new(git_tree_cache **out, const char *name, git_tree_cache *parent, git_pool *pool); int git_tree_cache_new(git_tree_cache **out, const char *name, git_pool *pool);
/** /**
* Read a tree as the root of the tree cache (like for `git read-tree`) * Read a tree as the root of the tree cache (like for `git read-tree`)
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment