Commit 8040f2a
authored
MINOR: [C++] Avoid multimap::find unspecified behavior (#48607)
### Rationale for this change
When a `std::multimap` has multiple entries with the same key, calling `m.find(key)` returns an unspecified element.
Historically, this returns the first matching element. However, this is not guaranteed, and recent libc++ changes make this return an arbitrary element. This can lead to surprising behavior, i.e. different values returned based on what other entries are in the multimap (and what the shape of the internal tree is).
### What changes are included in this PR?
Replace `m.find(key)` with `m.equal_range(key)` to preserve behavior and have predictable results. The behavior of this is guaranteed to return a range of all matching elements in insertion order, and the beginning of the range is the same element as what's normally returned by `m.find(key)`.
### Are these changes tested?
Yes
### Are there any user-facing changes?
No
Authored-by: Jordan Rupprecht <[email protected]>
Signed-off-by: David Li <[email protected]>1 parent de6eb89 commit 8040f2a
File tree
3 files changed
+24
-27
lines changed- cpp/src/arrow/flight/transport/grpc
3 files changed
+24
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
448 | 449 | | |
449 | 450 | | |
450 | 451 | | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
455 | 457 | | |
456 | 458 | | |
457 | 459 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
310 | | - | |
| 310 | + | |
| 311 | + | |
311 | 312 | | |
312 | | - | |
| 313 | + | |
313 | 314 | | |
314 | 315 | | |
315 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
| 58 | + | |
| 59 | + | |
60 | 60 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
67 | 65 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
74 | 70 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
81 | 75 | | |
82 | | - | |
| 76 | + | |
83 | 77 | | |
84 | 78 | | |
85 | 79 | | |
| |||
0 commit comments