Commit ecde5ae
Fix a bug in narrow limit
Summary:
The existing handling of the narrow depth limit is usesless! We wind up clearing
narrows whenever we're about to set a narrow, which is actually a no-op:
- We've already gotten the previous narrow when we computed the new narrow
- And then we clear the narrows, but we immediately overwrite it with the new
narrow
- That means we haven't done anything at all in terms of how the bindings work,
all we're accomplishing is writing to the same struct field twice in
succession
In addition, we know that 512 narrows is very likely too much, it will consume
a prohibitively large amount of stack space. The examples we've seen where the
limit gets hit are always generated files with a huge number of narrows at the
top level (and we probably would do best not narrowing at all for all such examples
seen so far), so I think a limit of 100 makes good sense - in practice I don't
think non-generated code would hit this limit, but it saves a lot more stack
usage when we do hit it.
This commit changes the logic so that we intercept narrowing depth in `idx()` and
we just ignore narrows at that point. The resulting behavior will be a bit different
because now we'll completely ignore narrows when we hit the limit (as opposed to
trying to reset at the raw value and then start narrowing again). I don't know
if this behavior is better per se but I think it's easier for a user to understand,
and again I think the limit is probably only going to be hit on generated code
anyway in practice.
Reviewed By: migeed-z
Differential Revision: D91717810
fbshipit-source-id: 173319aec29d11232ff31b3b457b8316636c1ddf1 parent 7aaabbd commit ecde5ae
2 files changed
+18
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
475 | | - | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
476 | 479 | | |
477 | 480 | | |
478 | 481 | | |
| |||
563 | 566 | | |
564 | 567 | | |
565 | 568 | | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
572 | 577 | | |
573 | 578 | | |
574 | 579 | | |
| |||
1679 | 1684 | | |
1680 | 1685 | | |
1681 | 1686 | | |
1682 | | - | |
1683 | | - | |
1684 | | - | |
1685 | | - | |
1686 | | - | |
| 1687 | + | |
1687 | 1688 | | |
1688 | 1689 | | |
1689 | 1690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
408 | | - | |
| 407 | + | |
| 408 | + | |
409 | 409 | | |
410 | | - | |
411 | 410 | | |
412 | 411 | | |
413 | | - | |
| 412 | + | |
414 | 413 | | |
415 | 414 | | |
416 | 415 | | |
| |||
519 | 518 | | |
520 | 519 | | |
521 | 520 | | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
526 | 524 | | |
527 | 525 | | |
0 commit comments