Sanae's blog

By Sanae, history, 7 months ago, In English

Code with Vector

Code with Array

Observation

Based on my testing, arrays are significantly faster than vectors in this scenario—specifically, around 14 to 15 times faster.

Revelation

For parameter lists with fixed lengths, use arrays for better performance. When dealing with dynamic lengths, vectors are more efficient for faster coding. However, performance can still be optimized using pointers in either case.

  • Vote: I like it
  • -33
  • Vote: I do not like it

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

maybe it's because copy by value vector, try reference?
I'm not sure whether that's the problem.

»
7 months ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

One shouldn't use vectors when the size is small and fixed.

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why there are so many downvotes?

If you are not satisfied with my content, please express your opinion.

  • »
    »
    7 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    It's because your code looks like shit.

    Please learn how to write readable code from the red coders

    • »
      »
      »
      7 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Thx.

      However, I was once a red coder QAQ.

      • »
        »
        »
        »
        7 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        Brilliant i see you were red. I think the downvotes are from lower rated coders which are a lot in number.

        Most low rated coders want easy to understand stuff but your post is just the opposite. Complex and terse.

        So maybe that's the reason for downvotes.

        • »
          »
          »
          »
          »
          7 months ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          Yeah, I get your point and will try to make myself clear.

          Thanks again!