mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 06:18:07 +03:00
63971e5fba
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
39 lines
807 B
C++
39 lines
807 B
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.
|
|
*/
|
|
|
|
#include "eden/fs/utils/Guid.h"
|
|
|
|
#ifdef _WIN32
|
|
#include <combaseapi.h> // @manual
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
|
|
|
namespace facebook::eden {
|
|
|
|
Guid Guid::generate() {
|
|
GUID id;
|
|
HRESULT result = CoCreateGuid(&id);
|
|
if (FAILED(result)) {
|
|
throw std::system_error(
|
|
result, HResultErrorCategory::get(), "Failed to create a GUID");
|
|
}
|
|
return Guid{id};
|
|
}
|
|
|
|
Guid::Guid(const std::string& s) {
|
|
auto ret = UuidFromStringA((RPC_CSTR)s.c_str(), &guid_);
|
|
if (ret != RPC_S_OK) {
|
|
throw makeWin32ErrorExplicit(
|
|
ret, fmt::format(FMT_STRING("Failed to parse UUID: {}"), s));
|
|
}
|
|
}
|
|
|
|
} // namespace facebook::eden
|
|
|
|
#endif
|