sapling/eden/fs/model/EntryAttributeFlags.h
Chad Austin 63971e5fba shave 5-7 seconds off C++ unit test compile times
Summary:
I was iterating on a single unit test and noticed our compilation times have
crossed the threshold from bad to horrific. I was seeing 30+ seconds per unit
test .cpp file.

After playing around with -ftime-trace, I found some obvious low-hanging fruit:
- forward declaration opportunities
- pImpl
- moving some implementation to cpp files

Some bigger opportunities remain:

The folly/portability/GTest.h and folly/portability/Windows.h header situation
isn't great. They pull in winsock2.h which alone takes two seconds to compile.
We also probably don't need the folly/portability/Unistd.h compatibility
wrappers in EdenFS or Watchman.

Also, folly/Format.h is quite expensive, and there are other dependencies that
pull in Boost MPL.

Reviewed By: xavierd

Differential Revision: D38195736

fbshipit-source-id: 9c64bab5ff5851d5a896674712aec71d6780c79a
2022-07-28 13:32:42 -07:00

38 lines
1.2 KiB
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 "eden/common/utils/OptionSet.h"
#include "eden/fs/service/gen-cpp2/eden_types.h"
namespace facebook::eden {
struct EntryAttributeFlags
: OptionSet<EntryAttributeFlags, std::underlying_type_t<FileAttributes>> {
constexpr static EntryAttributeFlags raw(FileAttributes raw) {
return OptionSet<
EntryAttributeFlags,
std::underlying_type_t<FileAttributes>>::raw(folly::to_underlying(raw));
}
constexpr static EntryAttributeFlags raw(
std::underlying_type_t<FileAttributes> raw) {
return OptionSet<
EntryAttributeFlags,
std::underlying_type_t<FileAttributes>>::raw(raw);
}
};
inline constexpr auto ENTRY_ATTRIBUTE_TYPE =
EntryAttributeFlags::raw(FileAttributes::SOURCE_CONTROL_TYPE);
inline constexpr auto ENTRY_ATTRIBUTE_SIZE =
EntryAttributeFlags::raw(FileAttributes::FILE_SIZE);
inline constexpr auto ENTRY_ATTRIBUTE_SHA1 =
EntryAttributeFlags::raw(FileAttributes::SHA1_HASH);
} // namespace facebook::eden