Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

11
  • 2
    the memcpy isn't a very good idea, since that would be comparable to just setting the values directly speed wise. Commented Jun 30, 2009 at 20:19
  • 1
    I don't see the need for the copy and the const array: Why not create the modifiable array in the first place with the pre-filled values? Commented Jun 30, 2009 at 20:20
  • Thanks for the speed explanation and how to do it if the speed is an issue with a large array size (which is in my case) Commented Jun 30, 2009 at 20:22
  • The initializer list is done at compile time and loaded at runtime. No need to go copying things around. Commented Jun 30, 2009 at 20:22
  • @litb, @Evan: For example gcc generates dynamic initialization (lots of movs) even with optimizations enabled. For large arrays and tight performance requirements, you want to do the init at compile time. memcpy is probably better optimized for large copies than lots of plain movs alone. Commented Jun 30, 2009 at 20:25