From b9d085c1b3f22cc2edd1273a8e95950a8abd4f1f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 19 Nov 2024 08:04:30 +0300 Subject: [PATCH] minor refactor --- res/layouts/console.xml.lua | 22 +++++++++++++++------- src/coders/xml.cpp | 2 +- src/coders/xml.hpp | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/res/layouts/console.xml.lua b/res/layouts/console.xml.lua index 8e73a136..f251e120 100644 --- a/res/layouts/console.xml.lua +++ b/res/layouts/console.xml.lua @@ -61,16 +61,24 @@ events.on("core:open_traceback", function(traceback_b64) else framestr = frame.source..":"..tostring(frame.currentline).." " if file.exists(frame.source) then - callback = "local source = file.read('"..frame.source.."') ".. - "document.editor.text = source ".. - "document.editor.focused = true ".. - "time.post_runnable(function() document.editor.caret = document.editor:linePos(".. - tostring(frame.currentline-1)..") end)" + callback = string.format( + "local editor = document.editor ".. + "local source = file.read('%s') ".. + "editor.text = source ".. + "editor.focused = true ".. + "time.post_runnable(function()".. + "editor.caret = editor:linePos(%s) ".. + "end)", + frame.source, frame.currentline-1 + ) else callback = "document.editor.text = 'Could not open source file'" end - callback = callback.." document.title.text = gui.str('File')..' - " - ..frame.source.."'" + callback = string.format( + "%s document.title.text = gui.str('File')..' - %s'", + callback, + frame.source + ) end if frame.name then framestr = framestr.."("..tostring(frame.name)..")" diff --git a/src/coders/xml.cpp b/src/coders/xml.cpp index ba2f36a9..3110d98a 100644 --- a/src/coders/xml.cpp +++ b/src/coders/xml.cpp @@ -337,7 +337,7 @@ xmldocument Parser::parse() { return document; } -xmldocument xml::parse(const std::string& filename, const std::string& source) { +xmldocument xml::parse(std::string_view filename, std::string_view source) { Parser parser(filename, source); return parser.parse(); } diff --git a/src/coders/xml.hpp b/src/coders/xml.hpp index 136c60df..54a2b589 100644 --- a/src/coders/xml.hpp +++ b/src/coders/xml.hpp @@ -140,6 +140,6 @@ namespace xml { /// @param source xml source code string /// @return xml document extern xmldocument parse( - const std::string& filename, const std::string& source + std::string_view filename, std::string_view source ); }