Browse Source

* wasm32 obj writer: use Data.ObjSectionList.Find to find the debug section by name in MaybeWriteDebugSection

Nikolay Nikolov 3 years ago
parent
commit
cc260eb7b2
1 changed files with 9 additions and 13 deletions
  1. 9 13
      compiler/ogwasm.pas

+ 9 - 13
compiler/ogwasm.pas

@@ -1401,23 +1401,19 @@ implementation
 
 
         procedure MaybeWriteDebugSection(const sn: string; st: TWasmCustomSectionType);
         procedure MaybeWriteDebugSection(const sn: string; st: TWasmCustomSectionType);
           var
           var
-            i: Integer;
             objsec: TWasmObjSection;
             objsec: TWasmObjSection;
           begin
           begin
-            for i:=0 to Data.ObjSectionList.Count-1 do
+            objsec:=TWasmObjSection(Data.ObjSectionList.Find(sn));
+            if Assigned(objsec) then
               begin
               begin
-                objsec:=TWasmObjSection(Data.ObjSectionList[i]);
-                if objsec.Name=sn then
+                if oso_Data in objsec.SecOptions then
                   begin
                   begin
-                    if oso_Data in objsec.SecOptions then
-                      begin
-                        objsec.Data.seek(0);
-                        CopyDynamicArray(objsec.Data,FWasmCustomSections[st],objsec.Size);
-                      end
-                    else
-                      WriteZeros(FWasmCustomSections[st],objsec.Size);
-                    WriteWasmCustomSection(st);
-                  end;
+                    objsec.Data.seek(0);
+                    CopyDynamicArray(objsec.Data,FWasmCustomSections[st],objsec.Size);
+                  end
+                else
+                  WriteZeros(FWasmCustomSections[st],objsec.Size);
+                WriteWasmCustomSection(st);
               end;
               end;
           end;
           end;