comparison src/map.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 9e6d5a4abb1c
children af1eca322b9e
comparison
equal deleted inserted replaced
18990:1219ae40b086 18991:847cc7932c42
695 mp->m_simplified = 695 mp->m_simplified =
696 did_simplify && keyround == 1; 696 did_simplify && keyround == 1;
697 #ifdef FEAT_EVAL 697 #ifdef FEAT_EVAL
698 mp->m_expr = expr; 698 mp->m_expr = expr;
699 mp->m_script_ctx = current_sctx; 699 mp->m_script_ctx = current_sctx;
700 mp->m_script_ctx.sc_lnum += sourcing_lnum; 700 mp->m_script_ctx.sc_lnum += SOURCING_LNUM;
701 #endif 701 #endif
702 did_it = TRUE; 702 did_it = TRUE;
703 } 703 }
704 } 704 }
705 if (mp->m_mode == 0) // entry can be deleted 705 if (mp->m_mode == 0) // entry can be deleted
794 mp->m_mode = mode; 794 mp->m_mode = mode;
795 mp->m_simplified = did_simplify && keyround == 1; 795 mp->m_simplified = did_simplify && keyround == 1;
796 #ifdef FEAT_EVAL 796 #ifdef FEAT_EVAL
797 mp->m_expr = expr; 797 mp->m_expr = expr;
798 mp->m_script_ctx = current_sctx; 798 mp->m_script_ctx = current_sctx;
799 mp->m_script_ctx.sc_lnum += sourcing_lnum; 799 mp->m_script_ctx.sc_lnum += SOURCING_LNUM;
800 #endif 800 #endif
801 801
802 // add the new entry in front of the abbrlist or maphash[] list 802 // add the new entry in front of the abbrlist or maphash[] list
803 if (abbrev) 803 if (abbrev)
804 { 804 {
1913 { 1913 {
1914 mapblock_T *mp; 1914 mapblock_T *mp;
1915 char_u *p; 1915 char_u *p;
1916 int i; 1916 int i;
1917 char_u buf[3]; 1917 char_u buf[3];
1918 char_u *save_name;
1919 int abbr; 1918 int abbr;
1920 int hash; 1919 int hash;
1921 buf_T *bp; 1920 buf_T *bp;
1922 1921
1923 validate_maphash(); 1922 validate_maphash();
1924 save_name = sourcing_name; 1923 // avoids giving error messages
1925 sourcing_name = (char_u *)"mappings"; // avoids giving error messages 1924 estack_push(ETYPE_INTERNAL, (char_u *)"mappings", 0);
1926 1925
1927 // Do this once for each buffer, and then once for global 1926 // Do this once for each buffer, and then once for global
1928 // mappings/abbreviations with bp == NULL 1927 // mappings/abbreviations with bp == NULL
1929 for (bp = firstbuf; ; bp = bp->b_next) 1928 for (bp = firstbuf; ; bp = bp->b_next)
1930 { 1929 {
1977 } 1976 }
1978 } 1977 }
1979 if (bp == NULL) 1978 if (bp == NULL)
1980 break; 1979 break;
1981 } 1980 }
1982 sourcing_name = save_name; 1981 estack_pop();
1983 } 1982 }
1984 1983
1985 #if defined(FEAT_EVAL) || defined(PROTO) 1984 #if defined(FEAT_EVAL) || defined(PROTO)
1986 /* 1985 /*
1987 * Check the string "keys" against the lhs of all mappings. 1986 * Check the string "keys" against the lhs of all mappings.