| |

VerySource

 Forgot password?
 Register
Search
Author: overdose

Simple little question ~!

[Copy link]

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-8-19 15:45:02
| Show all posts
The second is more efficient
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-19 16:00:01
| Show all posts
Try it yourself first to see if it makes a difference
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-19 16:15:01
| Show all posts
hannah2222


   
The difference is different, but the if() statement has little effect here, because if list1.size is used in this way, the list must be traversed every time to get its size. If the size attribute of the list is used repeatedly, it is best to First take it out and put it in the int variable. For example, there is such a statement for (;list.size;) {} It is better to use the latter method

  

______________
Support this, up
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list