This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Commit 36ae610
Stack<T> optimization of (Try)Peek, (Try)Pop and Push (#26086)
* Stack.Pop RCE
With value types the effect is not so big, because there is still one (manual) check for bounds.
For reference types one bounds-check can be saved, so there is a win.
* Applied same optimizations as for Pop on Peek, TryPeek, TryPop, Push
* Revert change for Push
I can't see a real win, sometimes it's faster and sometimes slower. On Linux the tendency is to be slower.
Therefore the state as is will be remained.
* Stack.Push with hot-/cold-path (PushWithResize)
* Addressed PR feedback
Cf. #26086 (comment)
* Array-copy in Peek is not necessary, JIT can do the same
As of PR-feedback #26086 (comment)
* Reverted b0bfd83
Cf. #26086 (comment)
* Addressed PR feedback
Cf. #26086 (comment)1 parent fc7cd1b commit 36ae610
File tree
1 file changed
+49
-15
lines changed- src/System.Collections/src/System/Collections/Generic
1 file changed
+49
-15
lines changedLines changed: 49 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
206 | 209 | | |
207 | 210 | | |
208 | 211 | | |
209 | 212 | | |
210 | | - | |
| 213 | + | |
211 | 214 | | |
212 | 215 | | |
213 | 216 | | |
214 | 217 | | |
215 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
216 | 222 | | |
217 | | - | |
| 223 | + | |
218 | 224 | | |
219 | 225 | | |
220 | | - | |
| 226 | + | |
221 | 227 | | |
222 | 228 | | |
223 | 229 | | |
224 | 230 | | |
225 | 231 | | |
226 | 232 | | |
227 | 233 | | |
228 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
229 | 241 | | |
230 | 242 | | |
231 | 243 | | |
232 | 244 | | |
233 | 245 | | |
234 | | - | |
| 246 | + | |
| 247 | + | |
235 | 248 | | |
236 | 249 | | |
237 | | - | |
| 250 | + | |
238 | 251 | | |
239 | 252 | | |
240 | 253 | | |
241 | 254 | | |
242 | 255 | | |
243 | 256 | | |
244 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
245 | 261 | | |
246 | | - | |
| 262 | + | |
247 | 263 | | |
248 | 264 | | |
249 | 265 | | |
250 | 266 | | |
251 | | - | |
| 267 | + | |
| 268 | + | |
252 | 269 | | |
253 | 270 | | |
254 | | - | |
| 271 | + | |
255 | 272 | | |
256 | 273 | | |
257 | 274 | | |
258 | 275 | | |
259 | 276 | | |
260 | 277 | | |
261 | 278 | | |
262 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
263 | 283 | | |
264 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
265 | 287 | | |
266 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
267 | 300 | | |
| 301 | + | |
268 | 302 | | |
269 | 303 | | |
270 | 304 | | |
| |||
0 commit comments