sapling/eden/fs/model/git/GitTree.h
Xavier Deguillard 2e9cce82d5 store: make BackingStore return shared_ptr instead of unique_ptr
Summary:
In both the ObjectStore and in the hg BackingStore, copies of the unique_ptr
were being made. For large blobs this is particularly inefficient as
potentially several MB (if not more) of data needs to be copied. Let's fix this
by changing the BackingStore API to return a shared_ptr.

In order to make the code easier to read and write, also define 3 types:
TreePtr, BlobPtr and BlobMetadataPtr and use them in the BackingStore code.
Future changes should be done at a later point to convert the whole codebase to
using these.

Reviewed By: chadaustin

Differential Revision: D45967102

fbshipit-source-id: 6086f95456232db48a5cbec47b7cf8b14e4424ed
2023-05-18 12:30:08 -07:00

26 lines
665 B
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include <folly/Range.h>
#include <folly/io/IOBuf.h>
#include "eden/fs/model/TreeFwd.h"
namespace facebook::eden {
class ObjectId;
/**
* Creates an Eden Tree from the serialized version of a Git tree object.
* As such, the SHA-1 of the gitTreeObject should match the hash.
*/
TreePtr deserializeGitTree(const ObjectId& hash, const folly::IOBuf* treeData);
TreePtr deserializeGitTree(const ObjectId& hash, folly::ByteRange treeData);
} // namespace facebook::eden