Isn't "delete" so pesky to type? Wish there was a better way?

Started by
18 comments, last by Digitalfragment 9 years, 8 months ago

Don't spread your propaganda.

The reason why it's faster is because the delete is optymized into a sse vector operation like Servant explained.

Advertisement

Oh you people. rolleyes.gif

For anyone who is legitimately confused, have fun researching C++'s comma operator. And yes, the comma operator can be overloaded; that might blow your mind. In fact, I bet with a templated overload of the comma operator, plus an appropriately designed class with an overloaded delete operator to represent a collection of deletable pointers, one could make ApochPiQ's code actual behave exactly as presented. Frightening. Too bad it would lose the 3x performance gain, heh! smile.png

"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke

If I get annoyed by repetitive typing, I just create functions to make things move along faster .

Very handy in Java were.this.is.very.common(to.see) .

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson

No, it's quite legit. It saves two trips to the heap by sending in three addresses at a time, and heap operations are very expensive!


That's not quite as ludicrous as it sounds. See the batch allocation/deallocate functions in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1527.pdf and implemented in nedmalloc. "heap operations" (depending on how you interpret that) actually are more expensive when done one at a time.

tongue.png

Sean Middleditch – Game Systems Engineer – Join my team!

Awesome! Does it works with HTML with variables? I'm planning to do a hockey MMO with it, might need it down the line.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

An example that might explain the operator's usage a bit more:


floor(*caek);
delete caek, this;

I'm sorry about any spelling or grammar mistakes or any undue brevity, as I'm most likely typing on my phone

"Hell, there's more evidence that we are just living in a frequency wave that flows in harmonic balance creating the universe and all its existence." ~ GDchat

How many codebases do you think already take advantage of this trick?

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

I'm pretty sure Gnome3 in it's first versions did. They probably needed that 3x perf increase to churn through all the constantly increasing amounts of memory they were using.

do not type delete- do not type new. Strange? Heretical? ok

Oh you people. rolleyes.gif

For anyone who is legitimately confused, have fun researching C++'s comma operator. And yes, the comma operator can be overloaded; that might blow your mind. In fact, I bet with a templated overload of the comma operator, plus an appropriately designed class with an overloaded delete operator to represent a collection of deletable pointers, one could make ApochPiQ's code actual behave exactly as presented. Frightening. Too bad it would lose the 3x performance gain, heh! smile.png

This is true. And for a few seconds after reading your post i seriously considered it. Then realized that i can implement it easier and safer through variadic templates!


template <typename T> void d(T *t) { delete t; }
template <typename T, typename... U> void d(T*t, U&... u) { delete t; d(u...); }

d(foo, bar, baz);

Not sure if i feel dirty or not...

This topic is closed to new replies.

Advertisement