comparison src/vim9compile.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
1399 int 1399 int
1400 get_script_item_idx(int sid, char_u *name, int check_writable) 1400 get_script_item_idx(int sid, char_u *name, int check_writable)
1401 { 1401 {
1402 hashtab_T *ht; 1402 hashtab_T *ht;
1403 dictitem_T *di; 1403 dictitem_T *di;
1404 scriptitem_T *si = &SCRIPT_ITEM(sid); 1404 scriptitem_T *si = SCRIPT_ITEM(sid);
1405 int idx; 1405 int idx;
1406 1406
1407 // First look the name up in the hashtable. 1407 // First look the name up in the hashtable.
1408 if (sid <= 0 || sid > script_items.ga_len) 1408 if (sid <= 0 || sid > script_items.ga_len)
1409 return -1; 1409 return -1;
1431 * Find "name" in imported items of the current script/ 1431 * Find "name" in imported items of the current script/
1432 */ 1432 */
1433 imported_T * 1433 imported_T *
1434 find_imported(char_u *name, cctx_T *cctx) 1434 find_imported(char_u *name, cctx_T *cctx)
1435 { 1435 {
1436 scriptitem_T *si = &SCRIPT_ITEM(current_sctx.sc_sid); 1436 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
1437 int idx; 1437 int idx;
1438 1438
1439 if (cctx != NULL) 1439 if (cctx != NULL)
1440 for (idx = 0; idx < cctx->ctx_imports.ga_len; ++idx) 1440 for (idx = 0; idx < cctx->ctx_imports.ga_len; ++idx)
1441 { 1441 {
1460 * Generate an instruction to load script-local variable "name". 1460 * Generate an instruction to load script-local variable "name".
1461 */ 1461 */
1462 static int 1462 static int
1463 compile_load_scriptvar(cctx_T *cctx, char_u *name) 1463 compile_load_scriptvar(cctx_T *cctx, char_u *name)
1464 { 1464 {
1465 scriptitem_T *si = &SCRIPT_ITEM(current_sctx.sc_sid); 1465 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
1466 int idx = get_script_item_idx(current_sctx.sc_sid, name, FALSE); 1466 int idx = get_script_item_idx(current_sctx.sc_sid, name, FALSE);
1467 imported_T *import; 1467 imported_T *import;
1468 1468
1469 if (idx == -1) 1469 if (idx == -1)
1470 { 1470 {