Commit 559c98f
src: prefer data accessor of string and vector
The pattern of getting the address of the element at index 0 of a
container is generally used to materialize a pointer to the backing
data of a container, however `std::string` and `std::vector`
provide a `data()` accessor to retrieve the data pointer which
should be preferred.
This also ensures that in the case that the container is empty, the
data pointer access does not perform an errant memory access.
PR-URL: #47750
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>1 parent e4539e1 commit 559c98fCopy full SHA for 559c98f
File tree
Expand file treeCollapse file tree
8 files changed
+15
-14
lines changedOpen diff view settings
Filter options
- src
- test/cctest
Expand file treeCollapse file tree
8 files changed
+15
-14
lines changedOpen diff view settings
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1750 | 1750 | |
1751 | 1751 | |
1752 | 1752 | |
1753 | | - |
| 1753 | + |
1754 | 1754 | |
1755 | 1755 | |
1756 | 1756 | |
|
Collapse file
+3-2Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
147 | 147 | |
148 | 148 | |
149 | 149 | |
150 | | - |
151 | | - |
| 150 | + |
| 151 | + |
| 152 | + |
152 | 153 | |
153 | 154 | |
154 | 155 | |
|
Collapse file
src/inspector_socket_server.cc
Copy file name to clipboardExpand all lines: src/inspector_socket_server.cc+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
136 | 136 | |
137 | 137 | |
138 | 138 | |
139 | | - |
| 139 | + |
140 | 140 | |
141 | 141 | |
142 | 142 | |
|
Collapse file
+2-2Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
754 | 754 | |
755 | 755 | |
756 | 756 | |
757 | | - |
| 757 | + |
758 | 758 | |
759 | | - |
| 759 | + |
760 | 760 | |
761 | 761 | |
762 | 762 | |
|
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1050 | 1050 | |
1051 | 1051 | |
1052 | 1052 | |
1053 | | - |
| 1053 | + |
1054 | 1054 | |
1055 | 1055 | |
1056 | 1056 | |
|
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
541 | 541 | |
542 | 542 | |
543 | 543 | |
544 | | - |
| 544 | + |
545 | 545 | |
546 | 546 | |
547 | 547 | |
|
Collapse file
+2-2Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
140 | 140 | |
141 | 141 | |
142 | 142 | |
143 | | - |
| 143 | + |
144 | 144 | |
145 | 145 | |
146 | 146 | |
| ||
156 | 156 | |
157 | 157 | |
158 | 158 | |
159 | | - |
| 159 | + |
160 | 160 | |
161 | 161 | |
162 | 162 | |
|
Collapse file
test/cctest/test_inspector_socket.cc
Copy file name to clipboardExpand all lines: test/cctest/test_inspector_socket.cc+4-4Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
764 | 764 | |
765 | 765 | |
766 | 766 | |
767 | | - |
768 | | - |
| 767 | + |
| 768 | + |
769 | 769 | |
770 | 770 | |
771 | 771 | |
| ||
778 | 778 | |
779 | 779 | |
780 | 780 | |
781 | | - |
782 | | - |
| 781 | + |
| 782 | + |
783 | 783 | |
784 | 784 | |
785 | 785 | |
|
0 commit comments