Mercurial > vim
comparison src/vim9execute.c @ 19191:133ef7ba4e4e v8.2.0154
patch 8.2.0154: reallocating the list of scripts is inefficient
Commit: https://github.com/vim/vim/commit/21b9e9773d64de40994f8762173bdd8befa6acf7
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 26 19:26:46 2020 +0100
patch 8.2.0154: reallocating the list of scripts is inefficient
Problem: Reallocating the list of scripts is inefficient.
Solution: Instead of using a growarray of scriptitem_T, store pointers and
allocate each scriptitem_T separately. Also avoids that the
growarray pointers change when sourcing a new script.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 26 Jan 2020 19:30:14 +0100 |
parents | 94eda51ba9ba |
children | 9f98957582d6 |
comparison
equal
deleted
inserted
replaced
19190:1483c87623da | 19191:133ef7ba4e4e |
---|---|
490 | 490 |
491 // load s: variable in vim9script | 491 // load s: variable in vim9script |
492 case ISN_LOADSCRIPT: | 492 case ISN_LOADSCRIPT: |
493 { | 493 { |
494 scriptitem_T *si = | 494 scriptitem_T *si = |
495 &SCRIPT_ITEM(iptr->isn_arg.script.script_sid); | 495 SCRIPT_ITEM(iptr->isn_arg.script.script_sid); |
496 svar_T *sv; | 496 svar_T *sv; |
497 | 497 |
498 sv = ((svar_T *)si->sn_var_vals.ga_data) | 498 sv = ((svar_T *)si->sn_var_vals.ga_data) |
499 + iptr->isn_arg.script.script_idx; | 499 + iptr->isn_arg.script.script_idx; |
500 if (ga_grow(&ectx.ec_stack, 1) == FAIL) | 500 if (ga_grow(&ectx.ec_stack, 1) == FAIL) |
596 break; | 596 break; |
597 | 597 |
598 // store script-local variable | 598 // store script-local variable |
599 case ISN_STORESCRIPT: | 599 case ISN_STORESCRIPT: |
600 { | 600 { |
601 scriptitem_T *si = &SCRIPT_ITEM( | 601 scriptitem_T *si = SCRIPT_ITEM( |
602 iptr->isn_arg.script.script_sid); | 602 iptr->isn_arg.script.script_sid); |
603 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) | 603 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) |
604 + iptr->isn_arg.script.script_idx; | 604 + iptr->isn_arg.script.script_idx; |
605 | 605 |
606 --ectx.ec_stack.ga_len; | 606 --ectx.ec_stack.ga_len; |
1549 get_vim_var_name(iptr->isn_arg.number)); | 1549 get_vim_var_name(iptr->isn_arg.number)); |
1550 break; | 1550 break; |
1551 case ISN_LOADSCRIPT: | 1551 case ISN_LOADSCRIPT: |
1552 { | 1552 { |
1553 scriptitem_T *si = | 1553 scriptitem_T *si = |
1554 &SCRIPT_ITEM(iptr->isn_arg.script.script_sid); | 1554 SCRIPT_ITEM(iptr->isn_arg.script.script_sid); |
1555 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) | 1555 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) |
1556 + iptr->isn_arg.script.script_idx; | 1556 + iptr->isn_arg.script.script_idx; |
1557 | 1557 |
1558 smsg("%4d LOADSCRIPT %s from %s", current, | 1558 smsg("%4d LOADSCRIPT %s from %s", current, |
1559 sv->sv_name, si->sn_name); | 1559 sv->sv_name, si->sn_name); |
1560 } | 1560 } |
1561 break; | 1561 break; |
1562 case ISN_LOADS: | 1562 case ISN_LOADS: |
1563 { | 1563 { |
1564 scriptitem_T *si = &SCRIPT_ITEM(iptr->isn_arg.loads.ls_sid); | 1564 scriptitem_T *si = SCRIPT_ITEM(iptr->isn_arg.loads.ls_sid); |
1565 | 1565 |
1566 smsg("%4d LOADS s:%s from %s", current, | 1566 smsg("%4d LOADS s:%s from %s", current, |
1567 iptr->isn_arg.string, si->sn_name); | 1567 iptr->isn_arg.string, si->sn_name); |
1568 } | 1568 } |
1569 break; | 1569 break; |
1587 smsg("%4d STOREG g:%s", current, iptr->isn_arg.string); | 1587 smsg("%4d STOREG g:%s", current, iptr->isn_arg.string); |
1588 break; | 1588 break; |
1589 case ISN_STORESCRIPT: | 1589 case ISN_STORESCRIPT: |
1590 { | 1590 { |
1591 scriptitem_T *si = | 1591 scriptitem_T *si = |
1592 &SCRIPT_ITEM(iptr->isn_arg.script.script_sid); | 1592 SCRIPT_ITEM(iptr->isn_arg.script.script_sid); |
1593 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) | 1593 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) |
1594 + iptr->isn_arg.script.script_idx; | 1594 + iptr->isn_arg.script.script_idx; |
1595 | 1595 |
1596 smsg("%4d STORESCRIPT %s in %s", current, | 1596 smsg("%4d STORESCRIPT %s in %s", current, |
1597 sv->sv_name, si->sn_name); | 1597 sv->sv_name, si->sn_name); |