问题描述
建议的新功能
int别名(void * ptr1,size_t len1,void * ptr1,size_t len2)
返回true如果指针重叠。
在大多数机器上,它可以简单地实现。但它必须是一个
标准库函数,因为从不同对象比较两个
地址不一定合法。
优势:
如果传递了不需要的别名,非智能实现只会执行用户的错误处理
代码。智能实现可以检测到两个指针不可能是别名,并生成moe
高效代码。
但是限制不会渗透到调用代码。没有
需要声明每个指针参数restict只是因为你在某处你b $ b调用一个库字符串副本。
A proposed new function
int alias(void *ptr1, size_t len1, void *ptr1, size_t len2)
Returns true if the pointers overlap.
On most machines it can be trivially implemented. However it has to be a
standard library function because it is not necessarily legal to compare two
address from different objects.
The advantages:
An unintelligent implementation simply executes the user''s error-handling
code if an unwanted alias is passed. An intelligent implementation can
detect that the two pointers cannot possibly be aliases, and generate moe
efficient code.
However the restrictions do not percolate up to calling code. There is no
need to declare every pointer parameter "restict" just because somewhere you
call a library string copy.
推荐答案
谁将指定len1和len2参数?
Who will specify the len1 and len2 parameters?
不确定是否使用了这样的功能。别名是关于编译时间
优化。您希望编译器生成如下代码:
if(别名(...))
{
// do "缓慢"代码
}
其他
{
//做快"代码
}
不确定这是否会加快速度:)
Not sure about the use of such a function. aliasing is about compiletime
optimization. You want a compiler to generate code like:
if (alias(...))
{
// do "slow" code
}
else
{
// do "fast" code
}
not sure if that would speed things up :)
入侵我的命名空间。请将其称为其他内容,例如isalias。
谢谢。
-
Richard Heathfield
" Usenet是一个奇怪的地方 - dmr 29/7/1999
电子邮件:rjh在上述域名中, - www。
invades my namespace. Please call it something else, e.g. isalias.
Thanks.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
这篇关于抗锯齿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!