Skip to content

Commit 23a7cec

Browse files
Mizuchimeta-codesync[bot]
authored andcommitted
change findStructuredAnnotation(...)'s input to LimitedVictor
Summary: We switched structured_annotations to `LimitedVector` This code works today since `const LimitedVector&` can be converted to `const std::vector<ThriftConstStruct>&` (since std::vector is the base class). Though it's better to make it more explicit and change the function to accept `LimitedVector`. Reviewed By: praihan Differential Revision: D85866372 fbshipit-source-id: 4e98dd95d9378346e5dcc57822ad148ad5889157
1 parent 14b9fce commit 23a7cec

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

third-party/thrift/src/thrift/lib/thrift/detail/MetadataAdapter.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
1-
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
216

317
#include "thrift/lib/thrift/detail/MetadataAdapter.h"
418
#include "thrift/lib/thrift/gen-cpp2/metadata_types.h"
519

620
namespace apache::thrift::metadata {
721

822
const ThriftConstStruct* findStructuredAnnotation(
9-
const std::vector<ThriftConstStruct>& annotations, std::string_view name) {
23+
const detail::LimitedVector<ThriftConstStruct>& annotations,
24+
std::string_view name) {
1025
for (const auto& i : annotations) {
1126
if (i.type()->name() == name) {
1227
return &i;
@@ -15,7 +30,8 @@ const ThriftConstStruct* findStructuredAnnotation(
1530
return nullptr;
1631
}
1732
const ThriftConstStruct& findStructuredAnnotationOrThrow(
18-
const std::vector<ThriftConstStruct>& annotations, std::string_view name) {
33+
const detail::LimitedVector<ThriftConstStruct>& annotations,
34+
std::string_view name) {
1935
if (const auto* p = findStructuredAnnotation(annotations, name)) {
2036
return *p;
2137
}

third-party/thrift/src/thrift/lib/thrift/detail/MetadataAdapter.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class LimitedVector : public std::vector<T> {
4949
} // namespace detail
5050

5151
const ThriftConstStruct* findStructuredAnnotation(
52-
const std::vector<ThriftConstStruct>& annotations, std::string_view name);
52+
const detail::LimitedVector<ThriftConstStruct>& annotations,
53+
std::string_view name);
5354
const ThriftConstStruct& findStructuredAnnotationOrThrow(
54-
const std::vector<ThriftConstStruct>& annotations, std::string_view name);
55+
const detail::LimitedVector<ThriftConstStruct>& annotations,
56+
std::string_view name);
5557
} // namespace apache::thrift::metadata

0 commit comments

Comments
 (0)