英文:
Create a variable as a reference for a long object in Go
问题
我有一个很长的对象update.PostType.RecievedFrom.Id
,我需要在程序中多次访问它,但我想要缩短它,使其更易读,通过创建一个变量id := update.PostType.RecievedFrom.Id
。现在我的问题是,这个变量是否是一个"零开销"的变量,并且会在编译时被替换为宏,还是它会影响我的程序(如果是的话,我该如何避免)?
英文:
I have a long object update.PostType.RecievedFrom.Id
that I need to access many times inside my program,
but I want to shorten it, so it will be more readable, by creating a variable for it id := update.PostType.RecievedFrom.Id
. now my question is would this variable be a "zero overhead" variable and will be just replaced as a macro in compile time, or it does affect my program (and if it is, how can I avoid it?)
答案1
得分: 5
> 在编译时,will be just replaced as a macro
会被替换为宏吗?
不会。
> 或者它会影响我的程序吗?
会有影响,但是非常微不足道。
> (如果有影响),我该如何避免它?
你无法避免,也不需要担心。
英文:
> will be just replaced as a macro in compile time [?]
No.
> or it does affect my program
Yes, but in a totally negligible way
> (and if it is, how can I avoid it?)
You cannot and you should not bother.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论