Skip to content

Commit 78ddbfb

Browse files
committed
Refactor cpp
1 parent aced1da commit 78ddbfb

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

content/cpp/false-sharing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ std::thread t2([&](){ increment(pb); });
9393
9494
This time, you will notice time takes turns out to be roughly half of what was observed earlier. For my machine, this new time was `300ms`.
9595
Again, we can get the IPC using `perf`
96-
```
96+
```shell
9797
$ perf stat ./a.out
9898
time: 297 ms
9999

content/cpp/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
title: C++
33
---
44

5+
- [[structs]], their sizes and space they take in memory
56
- [[atomic]]
6-
- [[structs]]
7-
- [[virtual-functions]]
7+
- [[virtual-functions]], polymorphism, vtables, dynamic dispatch
88
- [[constructors]]
9-
- [[templates]]
10-
- [[concepts]]
9+
- Advanced abstraction mechanism: [[templates]]
10+
- More advanced abstraction mechanism: [[concepts]]
1111
- [[false-sharing]]

content/cpp/structs.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@ Consider this peice of code
1111
```cpp
1212
struct emp {
1313
char c; // 1
14-
int x; // 4
14+
int x; // 4
1515
char d; // 1
1616
};
1717

1818
struct emp_with_padding {
1919
char c; // 1
2020
char pad[3];
21-
int x; // 4
21+
int x; // 4
2222
char d; // 1
2323
char pad[3];
2424
};
2525

2626
struct emp_reordered {
27-
int x;
27+
int x;
2828
char c;
2929
char d;
3030
};
3131

3232
#pragma pack(1)
3333
struct emp_pragma_packed {
34-
int x;
34+
int x;
3535
char c;
3636
char d;
3737
};
3838

3939
struct emp_packed {
40-
int x;
40+
int x;
4141
char c;
4242
char d;
4343
}__attribute__((__packed__));
@@ -59,9 +59,9 @@ GCC does not do structure reordering on itself because the structure might be se
5959
#include <iostream>
6060
6161
struct Order {
62-
int qty;
63-
int prc;
64-
char side; // buy or sell
62+
int qty;
63+
int prc;
64+
char side; // buy or sell
6565
char symbol[6]; // ticker symbol name
6666
};
6767
static_assert(sizeof(Order) == 16);

0 commit comments

Comments
 (0)