c++ - C++/WinRT:将关键字放在运行时类实现上是否有意义?
问题描述
我正在尝试最大化我的 UWP 客户端应用程序性能,以弥补我不是作者的缓慢后端。
在一些微软的视频中,我看到放入[noexcept]
IDL 类可以使方法调用更高效,但是它们的 C++ 实现呢?由于整个事物是基于 COM 的,并且这些方法的调用方式与原始 C++ 中的方式不同,因此是否会更改诸如inline
、之类的关键字noexcept
或更改任何内容?const
// MyViewModel.idl
namespace MyApp
{
[bindable]
[default_interface]
runtimeclass MyViewModel
{
MyViewModel();
[noexcept] Int32 MyProperty;
}
}
// MyViewModel.h
namespace winrt::MyApp::implementation
{
struct MyViewModel : MyViewModelT<MyViewModel>
{
MyViewModel() = default;
inline int32_t MyProperty() const noexcept;
inline void MyProperty(int32_t) noexcept;
private:
int32_t m_myProperty;
};
}
// MyViewModel.cpp
namespace winrt::MyApp::implementation
{
inline int32_t MyViewModel::MyProperty() const noexcept
{
return m_myProperty;
}
inline void MyViewModel::MyProperty(int32_t value) noexcept
{
m_myProperty = value;
}
}
此问题严格针对提到的关键字,请不要发布其他无关的优化提示。
解决方案
推荐阅读
- java - 数组元素可以等于整数的名称而不是值吗?
- c++ - 是否可以使用在另一个 C++ 库中声明的静态变量
- python - 在Python中从二维数组(列表列表)中删除字符串列表的有效方法?
- .net - 无法加载文件或程序集“System.ServiceModel.Primitives,版本=4.5.0.4,文化=中性,PublicKeyToken=b03f5f7f11d50a3a”
- wpf - WPF Controls.Webbrowser 不导航到 URL
- javascript - 如何获取 user_id 的“雪花”值?
- python - 蒙特卡罗模拟 - 一步生成 NxK 个随机变量或每个时间步生成 K 个随机变量 N 次
- python - 在 groupby 特定列之后查找最早日期
- javascript - react 创建动态组件
- python - 面向初学者的 BERT 文本分类任务