小编Mar*_*uss的帖子

Null vs ZeroMemory

将对象设置为NULL和使用ZeroMemory之间究竟有什么区别?

我听说在WinAPI(主要是C)中,一个人应该在C对象上使用ZeroMemory是一种很好的做法.我来自C#的背景,这似乎是一个C++人真正应该知道的东西.

我发现使用DirectX API,无论你是否ZeroMemory对象,应用程序仍然有效,但有些示例使用ZeroMemory,有些则没有.

任何人都可以澄清这些事情吗?

c c++ directx null winapi

5
推荐指数
2
解决办法
6919
查看次数

C++这是一种微优化形式

这是微优化,还是优化呢?

void Renderer::SetCamera(FLOAT x, FLOAT y, FLOAT z) {
    // Checking for zero before doing addition?
    if (x != 0) camX += x;
    if (y != 0) camY += y;
    if (z != 0) camZ += z;

    // Checking if any of the three variables are not zero, and performing the code below.
    if (x != 0 | y != 0 | z != 0) {
        D3DXMatrixTranslation(&w, camX, camY, camZ);
    }
}
Run Code Online (Sandbox Code Playgroud)

使用带有vector.size()的条件运行for循环会强制应用程序重新计算每个循环中向量中的元素吗?

std::vector<UINT> vect;

INT vectorSize = vect.size();
for …
Run Code Online (Sandbox Code Playgroud)

c++ micro-optimization

2
推荐指数
1
解决办法
261
查看次数

标签 统计

c++ ×2

c ×1

directx ×1

micro-optimization ×1

null ×1

winapi ×1