Mercurial > vim
comparison src/profiler.c @ 18991:847cc7932c42 v8.2.0056
patch 8.2.0056: execution stack is incomplete and inefficient
Commit: https://github.com/vim/vim/commit/1a47ae32cdc19b0fd5a82e19fe5fddf45db1a506
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 29 23:04:25 2019 +0100
patch 8.2.0056: execution stack is incomplete and inefficient
Problem: Execution stack is incomplete and inefficient.
Solution: Introduce a proper execution stack and use it instead of
sourcing_name/sourcing_lnum. Create a string only when used.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 29 Dec 2019 23:15:04 +0100 |
parents | ed222e264905 |
children | 133ef7ba4e4e |
comparison
equal
deleted
inserted
replaced
18990:1219ae40b086 | 18991:847cc7932c42 |
---|---|
600 func_line_start(void *cookie) | 600 func_line_start(void *cookie) |
601 { | 601 { |
602 funccall_T *fcp = (funccall_T *)cookie; | 602 funccall_T *fcp = (funccall_T *)cookie; |
603 ufunc_T *fp = fcp->func; | 603 ufunc_T *fp = fcp->func; |
604 | 604 |
605 if (fp->uf_profiling && sourcing_lnum >= 1 | 605 if (fp->uf_profiling && SOURCING_LNUM >= 1 |
606 && sourcing_lnum <= fp->uf_lines.ga_len) | 606 && SOURCING_LNUM <= fp->uf_lines.ga_len) |
607 { | 607 { |
608 fp->uf_tml_idx = sourcing_lnum - 1; | 608 fp->uf_tml_idx = SOURCING_LNUM - 1; |
609 // Skip continuation lines. | 609 // Skip continuation lines. |
610 while (fp->uf_tml_idx > 0 && FUNCLINE(fp, fp->uf_tml_idx) == NULL) | 610 while (fp->uf_tml_idx > 0 && FUNCLINE(fp, fp->uf_tml_idx) == NULL) |
611 --fp->uf_tml_idx; | 611 --fp->uf_tml_idx; |
612 fp->uf_tml_execed = FALSE; | 612 fp->uf_tml_execed = FALSE; |
613 profile_start(&fp->uf_tml_start); | 613 profile_start(&fp->uf_tml_start); |
904 sn_prl_T *pp; | 904 sn_prl_T *pp; |
905 | 905 |
906 if (current_sctx.sc_sid <= 0 || current_sctx.sc_sid > script_items.ga_len) | 906 if (current_sctx.sc_sid <= 0 || current_sctx.sc_sid > script_items.ga_len) |
907 return; | 907 return; |
908 si = &SCRIPT_ITEM(current_sctx.sc_sid); | 908 si = &SCRIPT_ITEM(current_sctx.sc_sid); |
909 if (si->sn_prof_on && sourcing_lnum >= 1) | 909 if (si->sn_prof_on && SOURCING_LNUM >= 1) |
910 { | 910 { |
911 // Grow the array before starting the timer, so that the time spent | 911 // Grow the array before starting the timer, so that the time spent |
912 // here isn't counted. | 912 // here isn't counted. |
913 (void)ga_grow(&si->sn_prl_ga, | 913 (void)ga_grow(&si->sn_prl_ga, |
914 (int)(sourcing_lnum - si->sn_prl_ga.ga_len)); | 914 (int)(SOURCING_LNUM - si->sn_prl_ga.ga_len)); |
915 si->sn_prl_idx = sourcing_lnum - 1; | 915 si->sn_prl_idx = SOURCING_LNUM - 1; |
916 while (si->sn_prl_ga.ga_len <= si->sn_prl_idx | 916 while (si->sn_prl_ga.ga_len <= si->sn_prl_idx |
917 && si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen) | 917 && si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen) |
918 { | 918 { |
919 // Zero counters for a line that was not used before. | 919 // Zero counters for a line that was not used before. |
920 pp = &PRL_ITEM(si, si->sn_prl_ga.ga_len); | 920 pp = &PRL_ITEM(si, si->sn_prl_ga.ga_len); |