From c8e4098fb233fe677f0eb59b714e15f9470af9d7 Mon Sep 17 00:00:00 2001 From: Samuel Gomes <47574584+a740g@users.noreply.github.com> Date: Sun, 10 Mar 2024 18:56:08 +0530 Subject: [PATCH] Optimize inline-data generation logic --- setup_mingw.cmd | 8 ++++---- source/qb64pe.bas | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/setup_mingw.cmd b/setup_mingw.cmd index 5250603a5..c255515ad 100644 --- a/setup_mingw.cmd +++ b/setup_mingw.cmd @@ -68,11 +68,11 @@ rem MINGW_DIR is actually the internal directory name inside the zip / 7z file rem It needs to be updated whenever the toolchains are updated if "%ARCH%" == "ARM" ( if %BITS% == 64 ( - set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-ucrt-aarch64.zip" - set MINGW_DIR=llvm-mingw-20231128-ucrt-aarch64 + set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20240308/llvm-mingw-20240308-ucrt-aarch64.zip" + set MINGW_DIR=llvm-mingw-20240308-ucrt-aarch64 ) else ( - set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-ucrt-armv7.zip" - set MINGW_DIR=llvm-mingw-20231128-ucrt-armv7 + set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20240308/llvm-mingw-20240308-ucrt-armv7.zip" + set MINGW_DIR=llvm-mingw-20240308-ucrt-armv7 ) set MINGW_TEMP_FILE=temp.zip ) else ( diff --git a/source/qb64pe.bas b/source/qb64pe.bas index 77e7af112..64f0b4d6a 100644 --- a/source/qb64pe.bas +++ b/source/qb64pe.bas @@ -228,9 +228,9 @@ IF os$ = "LNX" THEN BATCHFILE_EXTENSION = ".sh" IF MacOSX THEN BATCHFILE_EXTENSION = ".command" -DIM inlinedatastr(255) AS STRING +DIM inlinedatastr(0 TO 255) AS STRING FOR i = 0 TO 255 - inlinedatastr(i) = str2$(i) + "," + inlinedatastr(i) = "0x" + RIGHT$("0" + HEX$(i), 2) + "," NEXT @@ -11962,13 +11962,23 @@ ELSE 'inline data ff = OpenBuffer%("B", tmpdir$ + "data.bin") x$ = ReadBufRawData$(ff, GetBufLen&(ff)) - x2$ = "uint8 inline_data[]={" - FOR i = 1 TO LEN(x$) - x2$ = x2$ + inlinedatastr$(ASC(x$, i)) + + idsL = LEN(inlinedatastr(255)) + xL = LEN(x$) + + x2$ = SPACE$(xL * idsL) ' pre-allocate buffer + + x2Ofs = 1 + FOR i = 1 TO xL + MID$(x2$, x2Ofs, idsL) = inlinedatastr(ASC(x$, i)) + x2Ofs = x2Ofs + idsL NEXT - x2$ = x2$ + "0};" + + WriteBufLine GlobTxtBuf, "uint8 inline_data[]={" WriteBufLine GlobTxtBuf, x2$ + WriteBufLine GlobTxtBuf, "0};" WriteBufLine GlobTxtBuf, "uint8 *data=&inline_data[0];" + x$ = "": x2$ = "" END IF