From 2066415f82ba4fdda8d6f3020024d9fbf997e3da Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sun, 25 Jan 2009 21:09:41 -0500 Subject: Replaced str:match with str:find where applicable for speed improvements. --- core/ext/command_entry.lua | 6 +++--- core/ext/find.lua | 2 +- core/ext/keys.lua | 2 +- core/ext/mime_types.lua | 6 +++--- core/ext/pm/file_browser.lua | 2 +- core/ext/pm/modules_browser.lua | 4 ++-- core/ext/pm/project_browser.lua | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) (limited to 'core/ext') diff --git a/core/ext/command_entry.lua b/core/ext/command_entry.lua index 29e38bb6..c583dc06 100644 --- a/core/ext/command_entry.lua +++ b/core/ext/command_entry.lua @@ -16,18 +16,18 @@ function ce.get_completions_for(command) if type(tbl) ~= 'table' then return end local cmpls = {} for k in pairs(tbl) do - if type(k) == 'string' and k:match('^'..prefix) then + if type(k) == 'string' and k:find('^'..prefix) then cmpls[#cmpls + 1] = k end end if path == 'buffer' then if o == ':' then for f in pairs(textadept.buffer_functions) do - if f:match('^'..prefix) then cmpls[#cmpls + 1] = f end + if f:find('^'..prefix) then cmpls[#cmpls + 1] = f end end else for p in pairs(textadept.buffer_properties) do - if p:match('^'..prefix) then cmpls[#cmpls + 1] = p end + if p:find('^'..prefix) then cmpls[#cmpls + 1] = p end end end end diff --git a/core/ext/find.lua b/core/ext/find.lua index 0b26ba45..e6f7f529 100644 --- a/core/ext/find.lua +++ b/core/ext/find.lua @@ -102,7 +102,7 @@ function find.find(text, next, flags, nowrap, wrapped) end function search_dir(directory) for file in lfs.dir(directory) do - if not file:match('^%.') then + if not file:find('^%.') then local path = directory..'/'..file local type = lfs.attributes(path).mode if type == 'directory' then diff --git a/core/ext/keys.lua b/core/ext/keys.lua index 466a74c2..1a276861 100644 --- a/core/ext/keys.lua +++ b/core/ext/keys.lua @@ -151,7 +151,7 @@ local function keypress(code, shift, control, alt) if MAC and not shift and not control and not alt then local ch = string_char(code) -- work around native GTK-OSX's handling of Alt key - if ch:match('[^A-Za-z ]') and #keychain == 0 then + if ch:find('[^A-Za-z ]') and #keychain == 0 then buffer:add_text(ch) textadept.events.handle('char_added', ch) return true diff --git a/core/ext/mime_types.lua b/core/ext/mime_types.lua index 8ee41c7c..b35ee151 100644 --- a/core/ext/mime_types.lua +++ b/core/ext/mime_types.lua @@ -274,7 +274,7 @@ end -- [Local function] Sets the buffer's lexer language based on a shebang line. local function set_lexer_from_sh_bang() local line = buffer:get_line(0) - if line:match('^#!') then + if line:find('^#!') then line = line:gsub('[\\/]', ' ') for word in line:gmatch('%S+') do if shebangs[word] then @@ -291,7 +291,7 @@ end local function set_lexer_from_pattern() local line = buffer:get_line(0) for patt, lexer in pairs(patterns) do - if line:match(patt) then + if line:find(patt) then buffer:set_lexer_language(lexer) return true end @@ -310,7 +310,7 @@ local function load_language_module_from_filename(filename) local ret, err = pcall(require, lang) if ret then _m[lang].set_buffer_properties() - elseif not ret and not err:match("^module '"..lang.."' not found:") then + elseif not ret and not err:find("^module '"..lang.."' not found:") then textadept.events.error(err) end end diff --git a/core/ext/pm/file_browser.lua b/core/ext/pm/file_browser.lua index 87d4b8e6..7c03518a 100644 --- a/core/ext/pm/file_browser.lua +++ b/core/ext/pm/file_browser.lua @@ -23,7 +23,7 @@ function get_contents_for(full_path) local dir = {} local dirpath = table.concat(full_path, '/') for name in lfs.dir(dirpath) do - if not name:match('^%.') then + if not name:find('^%.') then dir[name] = { text = name } if lfs.attributes(dirpath..'/'..name, 'mode') == 'directory' then dir[name].parent = true diff --git a/core/ext/pm/modules_browser.lua b/core/ext/pm/modules_browser.lua index 757e7d93..5cf93d25 100644 --- a/core/ext/pm/modules_browser.lua +++ b/core/ext/pm/modules_browser.lua @@ -88,7 +88,7 @@ function get_contents_for(full_path) local dir = {} local dirpath = table.concat(full_path, '/') for name in lfs.dir(dirpath) do - if not name:match('^%.') then + if not name:find('^%.') then dir[name] = { text = name } if lfs.attributes(dirpath..'/'..name, 'mode') == 'directory' then dir[name].parent = true @@ -173,7 +173,7 @@ function perform_menu_action(menu_item, menu_id, selected_item) }) == '1' then local function remove_directory(dirpath) for name in lfs.dir(dirpath) do - if not name:match('^%.%.?$') then os.remove(dirpath..'/'..name) end + if not name:find('^%.%.?$') then os.remove(dirpath..'/'..name) end end lfs.rmdir(dirpath) end diff --git a/core/ext/pm/project_browser.lua b/core/ext/pm/project_browser.lua index 0219839e..9a6c078a 100644 --- a/core/ext/pm/project_browser.lua +++ b/core/ext/pm/project_browser.lua @@ -52,7 +52,7 @@ function get_contents_for(full_path) else local dirpath = full_path[#full_path] for name in lfs.dir(dirpath) do - if not name:match('^%.') then -- ignore hidden files + if not name:find('^%.') then -- ignore hidden files local filepath = dirpath..'/'..name contents[filepath] = { text = name } if lfs.attributes(dirpath..'/'..name, 'mode') == 'directory' then @@ -322,7 +322,7 @@ function perform_menu_action(menu_item, menu_id, selected_item) else local function remove_directory(dirpath) for name in lfs.dir(dirpath) do - if not name:match('^%.%.?$') then os.remove(dirpath..'/'..name) end + if not name:find('^%.%.?$') then os.remove(dirpath..'/'..name) end end lfs.rmdir(dirpath) end -- cgit v1.2.3