分配给自己:优化或多余的? [英] Assign to itself: optimization or extraneous?

查看:162
本文介绍了分配给自己:优化或多余的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我要通过非官方OpenGL库的glimg部分和整个东西来到我发现了奇怪的。在功能一个指针参数被分配给它,我看不出这可以完成任何事情。这是否在某种程度上迫使内存入高速缓存,或者是别的东西吗?可能是一个错误吗?

 静态UINT8 * resample_row_generic(UINT8 *总分,UINT8 * in_near,​​UINT8 * in_far,诠释W,诠释HS)
{
   //与近邻重采样
   INT I,J;
   in_far = in_far; //< - 在这里?
   对于(i = 0; I<瓦; ++ I)
      为(J = 0; J< HS; ++ j)条
         出[我* HS + J] = in_near [I]
   返回的;
}


解决方案

这是那里共进晚餐preSS的警告参数 in_far 在函数不使用

共进晚餐preSS警告另一种方法是:

 (无效)in_far;

So I was going through the glimg section of the unofficial OpenGL library and came across something I found strange. In one of the functions a pointer parameter is being assigned to itself and I can't see how this could be accomplishing anything. Does this somehow force memory into cache or is it something else? Possibly a bug?

static uint8 *resample_row_generic(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs)
{
   // resample with nearest-neighbor
   int i,j;
   in_far = in_far;  // <-- here?
   for (i=0; i < w; ++i)
      for (j=0; j < hs; ++j)
         out[i*hs+j] = in_near[i];
   return out;
}

解决方案

It's there to suppress the warning that the parameter in_far is not used in the function.

Another way to suppress the warning is:

(void)in_far;

这篇关于分配给自己:优化或多余的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆