|
From: Enno R. <enn...@gm...> - 2025-10-02 12:52:00
|
>> 1. C++ developers are never supposed to declare variables that start >> with "_" because that is reserved for internal compiler and library >> things. > > Its C++ you're working with, it mangles names. So you're probably not > clashing with anything. > Plus, [even though I personally don't like the habit], its common for > member variables to be prefixed with "_" or "m_" and if this were to > break things, then a LOT of c++ code would have been broken. The underscore for member variables is a C#-ism. It's also used in some languages (Python) to denote a private member variable. As to what the C (and C++) standards say, leading underscores aren't allowed in GLOBAL identifiers: https://rgambord.github.io/c99-doc/sections/7/1/3/index.html >> 2. That assignment statement in the above snippet is making a copy. If >> you pass by reference, there is no need to make a copy. Simply use >> the variable as if it were local. > > Yes, but that's where you could use the adopt() call. Of course you'd > lose the original at that point, but if this is a hand-over then that's > what you want. If its not a hand-over, one must make a copy. > > But passing by reference would at least avoid a 2nd copy. > > Just FYI, I have seen C++'s humble "reference &" gone AWOL, and if its > missing YUGE performance hit results. Everything continues to work, > but a giant copy can result. I'm also seeing more and more new developers who don't seem to know the importance of pass-by-reference. But I think educating them is outside the scope of this mailing list. That's what you pay your college for, and if they didn't teach it, you should ask for your money back. >> SELECT FROM WHERE <https://www.sqlitetutorial.net/sqlite-where/>. You >> can even ORDER BY. > > Yes, somewhere between big array and huge array you can switch to sqlite > or mysql [mariadb]. A full-on database will give you replication and > all sorts of other wonderful stuff. There are still situations where you want all your data in memory for performance. You wouldn't do large matrix multiplications or A* path finding on data stored in MySQL, for example. The problem occurs when you're (accidentally) copying lots of that data around. Enno. |