-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Add an efficient text stream write function #14821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
a6c5e7a
f8e6884
3d04d37
99f19a9
173e916
5040328
17e3ca5
f9fbb8a
d1163b5
94fbb52
3c5c3d4
934a06d
a99b9d6
99e669a
db89261
e77f2be
0ca2286
4b070fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,7 @@ | ||
/*++ | ||
Copyright (c) Microsoft Corporation | ||
Licensed under the MIT license. | ||
|
||
Module Name: | ||
- precomp.h | ||
|
||
Abstract: | ||
- Contains external headers to include in the precompile phase of console build process. | ||
- Avoid including internal project headers. Instead include them only in the classes that need them (helps with test project building). | ||
--*/ | ||
|
||
// stdafx.h : include file for standard system include files, | ||
// or project specific include files that are used frequently, but | ||
// are changed infrequently | ||
// | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
#pragma once | ||
|
||
// clang-format off | ||
|
||
// This includes support libraries from the CRT, STL, WIL, and GSL | ||
#include "LibraryIncludes.h" | ||
|
||
#pragma warning(push) | ||
#ifndef WIN32_LEAN_AND_MEAN | ||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers | ||
#define NOMCX | ||
#define NOHELP | ||
#define NOCOMM | ||
#endif | ||
|
||
// Windows Header Files: | ||
#include <windows.h> | ||
#include <intsafe.h> | ||
|
||
// private dependencies | ||
#include "../inc/unicode.hpp" | ||
#pragma warning(pop) | ||
#include <LibraryIncludes.h> | ||
|
||
// clang-format on | ||
#include <unicode.hpp> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
|
||
// Block minwindef.h min/max macros to prevent <algorithm> conflict | ||
#define NOMINMAX | ||
// Exclude rarely-used stuff from Windows headers | ||
#define WIN32_LEAN_AND_MEAN | ||
Comment on lines
+20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This prevents the inclusion of |
||
|
||
#include <algorithm> | ||
#include <atomic> | ||
|
@@ -52,21 +54,19 @@ | |
#include <vector> | ||
|
||
// WIL | ||
#include <wil/Common.h> | ||
#include <wil/Result.h> | ||
#include <wil/nt_result_macros.h> | ||
#include <wil/resource.h> | ||
#include <wil/wistd_memory.h> | ||
#include <wil/stl.h> | ||
#include <wil/com.h> | ||
#include <wil/stl.h> | ||
#include <wil/filesystem.h> | ||
#include <wil/win32_helpers.h> | ||
// Due to the use of RESOURCE_SUPPRESS_STL in result.h, we need to include resource.h first, which happens | ||
// implicitly through the includes above. If RESOURCE_SUPPRESS_STL is gone, the order doesn't matter anymore. | ||
#include <wil/result.h> | ||
#include <wil/nt_result_macros.h> | ||
|
||
// GSL | ||
// Block GSL Multi Span include because it both has C++17 deprecated iterators | ||
// and uses the C-namespaced "max" which conflicts with Windows definitions. | ||
#define GSL_MULTI_SPAN_H | ||
#include <gsl/gsl> | ||
#include <gsl/gsl_util> | ||
#include <gsl/pointers> | ||
|
||
// CppCoreCheck | ||
#include <CppCoreCheck/Warnings.h> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kinda weird that this is a static on textbuffer when it just does a
til::utf16_pop
, but presumably this does more in the future?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future I'll replace this function with some ICU code that actually advances the string by an entire grapheme cluster. So, if you have something like å ("a˚") it'll advance by 2 code points and not just 1 like it does now.
It's possible to just put the ICU code into
til
and use it throughout the code directly, just like we do it right now with the UTF-16 helpers. But from now on, I'd like to avoid doing that, even if it means writing suchstatic
methods, because I'd like to keep everything string handling related as close and tight as possible in the future. I thinkOutputCellIterator
had the same intention originally and was well meant, but it suffers from being a leaky abstraction. Lots of code is now built around an implicit assumption thatOutputCellIterator
will always advance by exactly 1 or 2 columns. Using thetil
UTF-16 helpers directly elsewhere in our code would have a similar effect in my opinion, because it would equally leak (and potentially incorrectly leak) any assumptions about howTextBuffer
handles incoming text under normal circumstances.