按地址呼叫与按值呼叫 [英] call by address vs. call by value

查看:66
本文介绍了按地址呼叫与按值呼叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么按地址呼叫?比按值调用更快?

解决方案

hasho< p7 ****** @ ccmail.ncku.edu.tw>潦草地写下:

为什么按地址呼叫?比按值调用更快?




这不一定。它可能是,但它可能不是。 C

标准没有定义什么比什么更快。这是

严格仅限于QoI问题。


-

/ - Joona Palaste(pa ***** @ cc.helsinki.fi)-------------芬兰-------- \

\-- http://www.helsinki.fi/~palaste ------------ ---------规则! -------- /

糟糕的事情只发生在恶棍身上。

- Moominmamma


*理想情况下*按地址调用更快,因为每次调用函数时,按值调用都会生成新副本



按地址调用不会复制相反,传递变量的地址为

是。


所以基本上速度问题来自制作产生的开销

变量的副本。


-

Elias

" hasho" < P7 ****** @ ccmail.ncku.edu.tw>在消息中写道

新闻:1a ************************** @ posting.google.c om ...

为什么按地址呼叫?是否比按值调用更快?



2004年2月10日04:35:52 -0800,正确的光荣
p7 ****** @ ccmail.ncku.edu.tw (hasho)写道:
< blockquote class =post_quotes>为什么按地址呼叫?比按值调用更快?




想到按价值调用hughe数据结构...


And顺便说一句。这两种方法不可互换而不会受到惩罚,因为您的问题可能会建议您使用

。它们完全不同于

性质。


frgr

Erik


Why is "call by address" faster than "call by value"?

解决方案

hasho <p7******@ccmail.ncku.edu.tw> scribbled the following:

Why is "call by address" faster than "call by value"?



It''s not necessarily. It could be, but then it could be not. The C
standard does not define anything about what is faster than what. It is
strictly a QoI issue only.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Bad things only happen to scoundrels."
- Moominmamma


*Ideally* call by address is faster because call by value makes a new copy
of the argument everytime you call the function.
Call by address does no copies instead pass the address of the variable as
is.

So basically the speed issue comes from the overhead produced by making
copies of the variables.

--
Elias
"hasho" <p7******@ccmail.ncku.edu.tw> wrote in message
news:1a**************************@posting.google.c om...

Why is "call by address" faster than "call by value"?



On 10 Feb 2004 04:35:52 -0800, the right honourable
p7******@ccmail.ncku.edu.tw (hasho) wrote:

Why is "call by address" faster than "call by value"?



think of calling a hughe data structure by value...

And, btw. the two methods are not interchangeable without penalty, as
may be suggested by your question. they are completely different in
nature.

frgr
Erik


这篇关于按地址呼叫与按值呼叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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