When are structs the answer?

前端 未结 12 954
广开言路
广开言路 2020-12-12 18:24

I\'m doing a raytracer hobby project, and originally I was using structs for my Vector and Ray objects, and I thought a raytracer was the perfect situation to use them: you

12条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 18:52

    Basically, don't make them too big, and pass them around by ref when you can. I discovered this the exact same way... By changing my Vector and Ray classes to structs.

    With more memory being passed around, it's bound to cause cache thrashing.

提交回复
热议问题