51
Elon: the U.S. Institute of Peace deleted 1TB of financial data linking them to funding Taliban & Iraqi leadership—but DOGE wasn’t fooled. They attempted to scrub the records, but DOGE engineers recovered the entire archive.     (pomf2.lain.la)
submitted by bossman131 to whatever 4 weeks ago (+52/-1)
28 comments last comment...
48
My Stance on the Tarrifs     (pomf2.lain.la)
submitted by bossman131 to random 3 weeks ago (+48/-0)
13 comments last comment...
48
Your enemy is not in Russia.     (pomf2.lain.la)
submitted by bossman131 to random 1 day ago (+49/-1)
18 comments last comment...
47
Remeber the Zika pysop? The truth is 'Finally' coming out     (pomf2.lain.la)
submitted by bossman131 to random 1 week ago (+48/-1)
11 comments last comment...
36
My Lucky Rock!     (pomf2.lain.la)
submitted by bossman131 to random 1 week ago (+36/-0)
4 comments last comment...
32
Covid IQ Test.     (pomf2.lain.la)
submitted by bossman131 to random 3 weeks ago (+32/-0)
34 comments last comment...
30
Too Risky?!     (pomf2.lain.la)
submitted by bossman131 to random 2 weeks ago (+30/-0)
9 comments last comment...
30
For this 136th year, let us remember how he brought men and women together     (pomf2.lain.la)
submitted by 15MAR to whatever 1 week ago (+30/-0)
6 comments last comment...
28
You dildo holders are famous     (pomf2.lain.la)
submitted by PenisEnvy to whatever 3 weeks ago (+29/-1)
22 comments last comment...
https://pomf2.lain.la/f/4ddhx8aw.jpg

Blue hairs got it blocked! Wtf
25
This is glorious. El Salvador just DENIED the 4 House Democrats' request to meet with Kilmar Garcia! Reason? "Not an official trip."     (pomf2.lain.la)
submitted by bossman131 to random 1 week ago (+26/-1)
10 comments last comment...
24
People Could Care Less About these retarded woke sports anymore. America is waking up. SAVE AMERICA     (pomf2.lain.la)
submitted by bossman131 to justice 3 weeks ago (+24/-0)
15 comments last comment...
23
Its their new Voter Base.     (pomf2.lain.la)
submitted by bossman131 to random 3 days ago (+23/-0)
3 comments last comment...
23
The Math doesnt Add up?     (pomf2.lain.la)
submitted by bossman131 to random 3 days ago (+23/-0)
16 comments last comment...
22
Zappa     (pomf2.lain.la)
submitted by boekanier to whatever 3 weeks ago (+22/-0)
3 comments last comment...
22
Approximately 44.6 million babies were murdered in the womb over the course of 2023, marking the fifth consecutive year in which abortion was the world’s leading cause of death.     (pomf2.lain.la)
submitted by bossman131 to random 9 hours ago (+22/-0)
15 comments last comment...
21
Its official, Canada is a Retard Country.     (pomf2.lain.la)
submitted by bossman131 to random 1 day ago (+21/-0)
42 comments last comment...
20
Got another chink scammer on the line. I love wasting their time. original content     (pomf2.lain.la)
submitted by SocksOnCats to whatever 3 weeks ago (+20/-0)
23 comments last comment...
18
Sneaky ass Bastards always trying to Blend In!     (pomf2.lain.la)
submitted by bossman131 to world 3 weeks ago (+18/-0)
0 comments...
18
There is almost perfect correlation between climate neurosis and voting Democrat.     (pomf2.lain.la)
submitted by bossman131 to ShowerThoughts 2 weeks ago (+18/-0)
10 comments last comment...
https://pomf2.lain.la/f/8121obqz.png

Challenging emotional response to climate change and other environmental issues. Extensive studies have been done on ecological anxiety since 2007, and various definitions remain in use. The condition is not a medical diagnosis and is regarded as a rational response to the reality of climate change; however, severe instances can have a mental health impact to left of center voters.

17
Did we just witness a Mass Extinction?     (pomf2.lain.la)
submitted by bossman131 to random 1 week ago (+17/-0)
2 comments last comment...
16
Oh, the plot thickens.     (pomf2.lain.la)
submitted by bossman131 to random 1 week ago (+16/-0)
5 comments last comment...
15
👌🏻     (pomf2.lain.la)
submitted by Kozel to conspiracy 2 weeks ago (+15/-0)
20 comments last comment...
15
These lines represent all known Atlantic Hurricanes since 1850. According to the press, the last few were caused by Donald Trump.     (pomf2.lain.la)
submitted by bossman131 to random 1 week ago (+16/-1)
7 comments last comment...
14
well planned     (pomf2.lain.la)
submitted by boekanier to DemonWorld 1 week ago (+14/-0)
3 comments last comment...
13
C++: When efficient operations and the language itself are one and the same     (pomf2.lain.la)
submitted by SithEmpire to C 4 weeks ago (+13/-0)
12 comments last comment...
https://pomf2.lain.la/f/819ag2cg.png

The linked image has formatting as intended originally; for the post text I had to use alternative characters to avoid triggering the site formatting, which REALLY needs a proper pre-formatted code feature.

Where most other languages have rules about passing primitive types by value and objects by reference, C/C++ builds subtle control of that into its language. This is no simple quirk; passing by value is also known as copying, and that comes with a real performance cost, such that learning a language which controls it is the nature of achieving good performance in and of itself.

Consider a simple and fairly useless class representing a square with a width and a height, entirely public to ignore encapsulation for now. We store the width and height, and we provide an area calculation and a function to scale its size:

class Square
{
public:
double width;
double height;

double area()
{
return width ✱ height;
}

void scale(double factor)
{
width ✱= factor;
height ✱= factor;
}

};

This works at least, but neither as optimally nor with as much freedom as it could have.

The freedom point is good to address first; consider how that area function. Despite only reading the class variables without changing them, the entire function will be treated as if it can conceivably change the Square object on which it is called. Due to that, the area function will be inaccessible given a const Square object, even though it makes no changes.

The area function should be specified like this:

double area() const
{
return width ✱ height;
}

Shoving const in the function header makes the object fields read-only within the function—in return for being allowed to call the function on a const version of the object. Use of const is both a means of object protection and also a precursor to compiler optimisations such as avoiding copying and reloads.

Now to be more optimal, consider the scale function. It modifies the object and thus cannot be const, but this is about the scale factor parameter. Calling that function will supply it with a copy of the factor, which can be appropriate if it genuinely needs a temporary copy it can modify without affecting the calling code, but clearly it doesn't change the factor. In one sense, it would be better to accept a reference instead:

void scale(double & factor)
{
width ✱= factor;
height ✱= factor;
}

This bypasses the overhead of copying, although now that function cannot be used with a const double, because it could conceivably change the value (even though in practice it doesn't). This applies to calls with literal number as the factor, such as scale(1.5)—that 1.5 is itself a const double.

The scale function should be specified like this:

void scale(const double & factor)
{
width ✱= factor;
height ✱= factor;
}

Introducing that guarantee now allows literal numbers and any named values (const or otherwise), while also avoiding copying anything.

Even though this example involves only a double weighing in at 8 bytes, that is nonetheless both how to talk to the C/C++ compiler and also how to avoid unnecessary copying. It is not an early optimisation mistake; it is a basic part of the language which should be in continual use, it just so happens that the language and the optimisation are one and the same!