{"id":312,"date":"2022-08-30T14:59:15","date_gmt":"2022-08-30T14:59:15","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/10\/17\/problem-about-shallow-copy-record-and-share-programming-errors\/"},"modified":"2022-08-30T14:59:15","modified_gmt":"2022-08-30T14:59:15","slug":"problem-about-shallow-copy-record-and-share-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-shallow-copy-record-and-share-programming-errors\/","title":{"rendered":"problem about shallow-copy-Record and share programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1b78f3904c9d9096f94176aa3dd06c2a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nShane MacLaughlin<br \/>\nc++ performance shallow-copy<br \/>\nSay I have a class, something like the following;class MyClass { public:MyClass();int a,b,c;double x,y,z; };#define PageSize 1000000MyClass Array1[PageSize],Array2[PageSize];If my class has not pointers or virtual methods, is it safe to use the following?memcpy(Array1,Array2,PageSize*sizeof(MyClass));The reason I ask, is that I&#8217;m dealing with very large collections of paged data, as decribed here, where performance is critical, and memcpy offers significant performance advanta<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-10-17 01:48:58. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Shane MacLaughlin c++ performance shallow-copy Say I have a class, something like the following;class MyClass { public:MyClass();int a,b,c;double x,y,z; };#define PageSize 1000000MyClass Array1[PageSize],Array2[PageSize];If my class has not pointers or virtual methods, is it safe to use the following?memcpy(Array1,Array2,PageSize*sizeof(MyClass));The reason I ask, is that I&#8217;m dealing with very large collections of paged data, as decribed here, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-312","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=312"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/312\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}