<ostream> -> <iosfwd>
<ostream> is one of the more expensive headers to include and that's amplified by SkRefCnt.h's popularity. We've been including <ostream> for sk_sp's operator<<. That's only used by Chromium and while we could just sprinkle in a bunch of .get() calls and remove operator<<, when I started going through and actually doing that I got the feeling I was making things pointlessly harder to read and write, and wanted to find a way to make it actually work. My next instinct was to template it without mentioning ostreams, template <typename OS, typename T> auto operator<<(OS& os, const sk_sp<T>& sp) -> decltype(os << sp.get()) { return os << sp.get(); } but that makes this operator<< ambiguous with some other templated operator<< in GTest. They got in first, so they win... So ultimately, switch <ostream> to <iosfwd>. Anyone using our operator<<() presumably has <ostream> included already, and the #include cost for <iosfwd> is small enough that I don't think we'll mind keeping this around indefinitely. To repro, look at before/after of -ftime-trace: ~/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang++ -I. -Os -c src/core/SkCanvas.cpp -ftime-trace I have tested locally that Chromium builds with this change. Change-Id: I9decc2e65b5cc8fd07d8106a5eff81901aedd7d5 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/237190 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
e384df4f5e
commit
48e08aa973
@ -13,8 +13,8 @@
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <iosfwd>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "include/core/SkFontStyle.h"
|
||||
#include "modules/skparagraph/include/DartTypes.h"
|
||||
#include "modules/skparagraph/include/TextStyle.h"
|
||||
#include <string> // std::u16string
|
||||
|
||||
namespace skia {
|
||||
namespace textlayout {
|
||||
|
@ -15,6 +15,10 @@
|
||||
#if defined(SKVM_JIT)
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#if defined(SKVM_PERF_DUMPS)
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
namespace skvm {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user