mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
These were defined inline in headers reached by most of the toolchain, and as non-template functions their bodies -- including some very expensive template instantiations -- are compiled in every including TU even though they are only cold debug/dump paths: - BundleStore's YAML output entry points instantiate IdAndKind::Dispatch over all ~50 ID kinds (two ~365ms instantiations per TU) plus Yaml::OutputScalar/std::function machinery; moved to a new bundle.cpp. - TypeStore, ConstantValueStore, NameStoreWrapper, and SharedValueStores OutputYaml bodies wrap capturing lambdas in std::function via Yaml::OutputMapping; moved to their existing .cpp files. This change appears to be worth another 10% compile time reduction. Assisted-by: Claude
38 lines
1.4 KiB
C++
38 lines
1.4 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "toolchain/base/shared_value_stores.h"
|
|
|
|
#include "toolchain/base/canonical_value_store_impl.h"
|
|
#include "toolchain/base/value_store_impl.h"
|
|
|
|
namespace Carbon {
|
|
|
|
template class CanonicalValueStore<FloatId, llvm::APFloat>;
|
|
template class CanonicalValueStore<IdentifierId, llvm::StringRef>;
|
|
template class CanonicalValueStore<StringLiteralValueId, llvm::StringRef>;
|
|
template class ValueStore<FloatId, llvm::APFloat>;
|
|
template class ValueStore<IdentifierId, llvm::StringRef>;
|
|
template class ValueStore<RealId, Real>;
|
|
template class ValueStore<StringLiteralValueId, llvm::StringRef>;
|
|
|
|
auto SharedValueStores::OutputYaml(
|
|
std::optional<llvm::StringRef> filename) const -> Yaml::OutputMapping {
|
|
return Yaml::OutputMapping([&, filename](Yaml::OutputMapping::Map map) {
|
|
if (filename) {
|
|
map.Add("filename", *filename);
|
|
}
|
|
map.Add("shared_values",
|
|
Yaml::OutputMapping([&](Yaml::OutputMapping::Map map) {
|
|
map.Add("ints", ints_.OutputYaml());
|
|
map.Add("reals", reals_.OutputYaml());
|
|
map.Add("floats", floats_.OutputYaml());
|
|
map.Add("identifiers", identifiers_.OutputYaml());
|
|
map.Add("strings", string_literals_.OutputYaml());
|
|
}));
|
|
});
|
|
}
|
|
|
|
} // namespace Carbon
|