From 91d0f5817d57813b2630812185389859b50445b7 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 15 Jun 2018 20:19:25 +0100 Subject: [PATCH] Refactor: inline methods --- .../net/kemitix/gitdb/impl/GitDBRepo.java | 32 ++----------------- .../net/kemitix/gitdb/impl/InitGitDBRepo.java | 4 +-- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/src/main/java/net/kemitix/gitdb/impl/GitDBRepo.java b/src/main/java/net/kemitix/gitdb/impl/GitDBRepo.java index c7e1102..388270c 100644 --- a/src/main/java/net/kemitix/gitdb/impl/GitDBRepo.java +++ b/src/main/java/net/kemitix/gitdb/impl/GitDBRepo.java @@ -56,17 +56,6 @@ class GitDBRepo { headWriter = new HeadWriter(repository); } - /** - * Insert a blob into the store, returning its unique id. - * - * @param blob content of the blob - * @return the id of the blob - * @throws IOException the blob could not be stored - */ - ObjectId insertBlob(final byte[] blob) throws IOException { - return valueWriter.write(blob); - } - /** * Insert a new, empty tree into the store, returning its unique id. * @@ -82,23 +71,6 @@ class GitDBRepo { return keyWriter.writeFirst(key, valueId); } - /** - * Insert a tree into the store, copying the exiting tree from the branch, returning its new unique id. - * - * @param branchRef the branch to copy the tree from - * @param key the key to insert - * @param valueId id of the value - * @return the id of the inserted tree - * @throws IOException the tree could not be stored - */ - ObjectId insertTree( - final Ref branchRef, - final String key, - final ObjectId valueId - ) throws IOException { - return keyWriter.write(key, valueId, branchRef); - } - /** * Insert a commit into the store, returning its unique id. * @@ -154,8 +126,8 @@ class GitDBRepo { * @throws IOException if there was an error writing the value */ ObjectId writeValue(final Ref branchRef, final String key, final String value) throws IOException { - final ObjectId blob = insertBlob(value.getBytes(StandardCharsets.UTF_8)); - return insertTree(branchRef, key, blob); + final ObjectId blob = valueWriter.write(value.getBytes(StandardCharsets.UTF_8)); + return keyWriter.write(key, blob, branchRef); } /** diff --git a/src/main/java/net/kemitix/gitdb/impl/InitGitDBRepo.java b/src/main/java/net/kemitix/gitdb/impl/InitGitDBRepo.java index ee65fbd..d99de8b 100644 --- a/src/main/java/net/kemitix/gitdb/impl/InitGitDBRepo.java +++ b/src/main/java/net/kemitix/gitdb/impl/InitGitDBRepo.java @@ -66,8 +66,8 @@ class InitGitDBRepo { private void createInitialBranchOnMaster(final Repository repository) throws IOException { final GitDBRepo repo = new GitDBRepo(repository); - final ObjectId objectId = - repo.insertBlob(GitDB.VERSION.toString().getBytes(StandardCharsets.UTF_8)); + final ValueWriter valueWriter = new ValueWriter(repository); + final ObjectId objectId = valueWriter.write(GitDB.VERSION.toString().getBytes(StandardCharsets.UTF_8)); final ObjectId treeId = repo.insertNewTree(GIT_DB_VERSION, objectId); final ObjectId commitId = repo.initialCommit(treeId, INIT_MESSAGE, INIT_USER, INIT_EMAIL); createBranch(repository, commitId, MASTER);