未验证 提交 d03fc452 编写于 作者: L Levi Broderick 提交者: GitHub

Remove custom copy of PtrToStringChars (#3117)

上级 6866a67f
......@@ -6,6 +6,7 @@
#define __COMMON_H
#include "precomp.hxx"
#include <vcclr.h>
using namespace System::Security;
......@@ -64,7 +65,7 @@ public:
__declspec(noinline) const cli::interior_ptr<const System::Char> static GetPtrToStringChars(System::String^ s)
{
return CriticalPtrToStringChars(s);
return PtrToStringChars(s);
}
......
......@@ -263,7 +263,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
{
System::String^ uriString = uri->AbsoluteUri;
IDWriteFontCollection* dwriteFontCollection = NULL;
pin_ptr<const WCHAR> uriPathWChar = CriticalPtrToStringChars(uriString);
pin_ptr<const WCHAR> uriPathWChar = PtrToStringChars(uriString);
IntPtr pIDWriteFontCollectionLoaderMirror = Marshal::GetComInterfaceForObject(
_wpfFontCollectionLoader,
......@@ -301,7 +301,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
if (isLocal)
{
//Protect the pointer to the filepath from being moved around by the garbage collector.
pin_ptr<const WCHAR> uriPathWChar = CriticalPtrToStringChars(filePathUri->LocalPath);
pin_ptr<const WCHAR> uriPathWChar = PtrToStringChars(filePathUri->LocalPath);
// DWrite currently has a slow lookup for the last write time, which
// introduced a noticable perf regression when we switched over.
......@@ -387,7 +387,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
{
System::String^ filePath = filePathUri->AbsoluteUri;
//Protect the pointer to the filepath from being moved around by the garbage collector.
pin_ptr<const WCHAR> uriPathWChar = CriticalPtrToStringChars(filePath);
pin_ptr<const WCHAR> uriPathWChar = PtrToStringChars(filePath);
IntPtr pIDWriteFontFileLoaderMirror = Marshal::GetComInterfaceForObject(
fontFileLoader,
......
......@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
#include "FontCollection.h"
#include <wpfvcclr.h>
namespace MS { namespace Internal { namespace Text { namespace TextInterface
{
......
......@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
#include "LocalizedStrings.h"
#include "wpfvcclr.h"
namespace MS { namespace Internal { namespace Text { namespace TextInterface
{
......@@ -144,7 +143,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
}
else
{
pin_ptr<const wchar_t> localeNameWChar = CriticalPtrToStringChars(localeName);
pin_ptr<const wchar_t> localeNameWChar = PtrToStringChars(localeName);
BOOL exists = FALSE;
UINT32 localeNameIndex = 0;
HRESULT hr = _localizedStrings->Value->FindLocaleName(
......
......@@ -4,8 +4,6 @@
#include "precomp.hxx"
#include "util2.h"
#include <wpfvcclr.h>
namespace MS { namespace Internal { namespace FontCache {
......@@ -15,7 +13,7 @@ bool Util2::GetRegistryKeyLastWriteTimeUtc(System::String ^ registryKey, [System
{
HKEY hkey = NULL;
pin_ptr<const wchar_t> registryKeyUnmanaged = CriticalPtrToStringChars(registryKey);
pin_ptr<const wchar_t> registryKeyUnmanaged = PtrToStringChars(registryKey);
if (::RegOpenKeyExW(HKEY_LOCAL_MACHINE, registryKeyUnmanaged, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
{
......
......@@ -4,6 +4,7 @@
#pragma once
#include <vcclr.h>
namespace MS { namespace Internal { namespace FontCache {
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//------------------------------------------------------------------------------
// This file is a copy of <vcclr.h>, with modifications necessary for WPF.
//------------------------------------------------------------------------------
#if _MSC_VER > 1000
#pragma once
#endif
#if !defined(_INC_WPFVCCLR)
#define _INC_WPFVCCLR
#ifndef RC_INVOKED
#using <mscorlib.dll>
#include <gcroot.h>
#pragma warning(push)
#pragma warning(disable:4400)
#ifdef __cplusplus_cli
typedef cli::interior_ptr<const System::Char> __const_Char_ptr;
typedef cli::interior_ptr<const System::Byte> __const_Byte_ptr;
typedef cli::interior_ptr<System::Byte> _Byte_ptr;
typedef const System::String^ __const_String_handle;
#define _NULLPTR nullptr
#else
typedef const System::Char* __const_Char_ptr;
typedef const System::Byte* __const_Byte_ptr;
typedef System::Byte* _Byte_ptr;
typedef const System::String* __const_String_handle;
#define _NULLPTR 0
#endif
/// <remarks>
/// The standard PtrToStringChars function in vcclr.h is not annotated as
/// SecurityCritical. A recent change to the compiler detects this and
/// prevents it from being inlined. For some reason, this now causes
/// JIT-ing the first time this method is called. This JIT happens in a
/// startup code path that is sensitive to perf. So we make a copy here
/// and annotate it.
/// </remarks>
inline __const_Char_ptr CriticalPtrToStringChars(__const_String_handle s)
{
_Byte_ptr bp = const_cast<_Byte_ptr>(reinterpret_cast<__const_Byte_ptr>(s));
if( bp != _NULLPTR )
{
unsigned offset = System::Runtime::CompilerServices::RuntimeHelpers::OffsetToStringData;
bp += offset;
}
return reinterpret_cast<__const_Char_ptr>(bp);
}
#pragma warning(pop)
#undef _NULLPTR
#endif /* RC_INVOKED */
#endif //_INC_WPFVCCLR
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册