无法优化for循环 [英] Trouble optimizing for-loop

查看:89
本文介绍了无法优化for循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这实际上是一个非常简单的递归(for-loop),但是我在优化它时遇到了一些麻烦,以便它运行得更快。

This is actaully a really simple recursion (for-loop), but I''m having some trouble optimizing it so that it would run faster.

展开 | 选择 | Wrap | 行号

推荐答案


这是一个非常简单的递归(for-loop),但我是在优化它时遇到一些麻烦,以便它运行得更快。

This is actaully a really simple recursion (for-loop), but I''m having some trouble optimizing it so that it would run faster.

展开 | 选择 | Wrap | 行号


我有一个计时器,用于计算函数所需的时间,大约40-就像我说的50秒,我还没有做任何事情来优化它,是否有任何方法可以优化从函数到数组的变量的提取/存储?
I do have a timer that calculates how long the function takes, and its roughly 40-50 seconds like I said, and I haven''t been able to do anything to optimize it just yet, is there any method to optimize the extraction/storage of the variables from the function to the array?

好吧,如果你在c ++中工作,你可以返回引用,这将避免从函数到你的数组的不必要的复制。


Savage
Well, if you are working in c++ you can return reference, this will avoid unnecessary copying from function to your array.

Savage


这篇关于无法优化for循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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