Skip to content

Experimental reimplementations of some Windows API functions taking std::wstring_view as argument

Notifications You must be signed in to change notification settings

tringi/win32-wstring_view

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Win32 API support for std::wstring_view

Experimental reimplementations of some Windows API functions taking std::wstring_view as argument

The problem

Modern C++ and other languages today provide extensive facilities to efficiently work with strings, especially with substrings, that aren't NUL-terminated. But a vast majority of Windows API function calls, e.g. CreateFile, consume their string argument(s) via NUL-terminated strings. This forces the application to allocate an unnecessary NUL-terminated copy of the string.

Those Win32 API functions then convert these parameters into UNICODE_STRINGs before passing it to appropiate NT API(s). UNICODE_STRING is basically a potentially-owning limited-size wstring_view.

This effectively means Windows is vasting millions of cycles a second by doing allocations and copying that's unnecessary.

This repository

If Windows were to implement parallel set of Win32 APIs to support std::wstring_view, what could they look like?

Note: Microsoft would probably use two parameters, LPWCSTR and SIZE_T, but we can afford actual std::wstring_view for our experiments.

Better solutions

Implemented functions

About

Experimental reimplementations of some Windows API functions taking std::wstring_view as argument

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages