mirror of
https://github.com/facebook/sapling.git
synced 2024-12-31 00:53:47 +03:00
Migrate to optional_field_ref Thrift API
Summary: Migrate the code from accessing optional Thrift fields directly to a safer `optional_field_ref` API. See https://fburl.com/safe for more details. The output of this codemod has been reviewed in D13259011. To preserve semantics, each unchecked access is replaced with an explicit call to `value_unchecked()`. If you are sure that accessing a field is safe (the field is marked as set), you can later replace `value_unchecked()` with `value()` or dereferencing (`operator *`): ``` ThriftStruct s = ... - auto foo = s.foo_ref().value_unchecked(); + auto foo = *s.foo_ref(); // will throw if s.foo is unset ``` drop-conflicts Reviewed By: stevegury Differential Revision: D15786632 fbshipit-source-id: 7c3f089dfa79597b189da6996cb76dcdbd5ed612
This commit is contained in:
parent
8d8007a0dc
commit
e4575f33be
@ -97,7 +97,7 @@ folly::Future<std::unique_ptr<Tree>> MononokeThriftBackingStore::getTree(
|
||||
Hash(file.hash.hash),
|
||||
file.name,
|
||||
treeEntryTypeFromMononoke(file.file_type),
|
||||
file.size,
|
||||
file.size_ref().value_unchecked(),
|
||||
Hash(file.content_sha1_ref().value_unchecked()));
|
||||
} else {
|
||||
entries.emplace_back(
|
||||
|
Loading…
Reference in New Issue
Block a user