/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/ReactCommon/react/renderer/core/RawPropsKeyMap.h
60 строк
2 KB
Samuel Susla
Remove Folly::small_vector (#39442)
16 сен 2023, 19:41
16 сен 2023, 19:41
d053137
Код
Авторство
О чём код?
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <react/renderer/core/RawPropsKey.h> #include <react/renderer/core/RawPropsPrimitives.h> #include <vector> namespace facebook::react { /* * A map especially optimized to hold `{name: index}` relations. * The implementation is conceptually similar to a classic hash map with a hash * function that returns the length of the string. * The map is optimized for reads only (the map must be reindexed before a bunch * of reads). */ class RawPropsKeyMap final { public: /* * Stores `value` with by given `key`. */ void insert(const RawPropsKey& key, RawPropsValueIndex value) noexcept; /* * Reindexes the stored data. * Must be called before `at` (after calling a bunch of `add`s). */ void reindex() noexcept; /* * Finds and returns the `value` (some index) by given `key`. * Returns `kRawPropsValueIndexEmpty` if the value wan't found. */ RawPropsValueIndex at( const char* name, RawPropsPropNameLength length) noexcept; private: struct Item { RawPropsValueIndex value; RawPropsPropNameLength length; char name[kPropNameLengthHardCap]; }; static bool shouldFirstOneBeBeforeSecondOne( const Item& lhs, const Item& rhs) noexcept; static bool hasSameName(const Item& lhs, const Item& rhs) noexcept; std::vector<Item> items_{}; std::vector<RawPropsPropNameLength> buckets_{}; }; } // namespace facebook::react