Move two things out of the lock

This commit is contained in:
Matt Nadareski
2025-09-20 22:32:54 -04:00
parent b7f782c1b7
commit f0ce58a79e

View File

@@ -2029,22 +2029,19 @@ namespace SabreTools.Serialization.Wrappers
/// <returns>Section strings on success, null on error</returns>
public List<string>? GetSectionStrings(int index)
{
// If we have no sections
if (SectionNames.Length == 0 || SectionTable == null || SectionTable.Length == 0)
return null;
// If the section doesn't exist
if (index < 0 || index >= SectionTable.Length)
return null;
lock (_sectionStringDataLock)
{
// If we have no sections
if (SectionNames.Length == 0 || SectionTable == null || SectionTable.Length == 0)
{
_sectionStringData = [];
return null;
}
// Create the section string array if we have to
_sectionStringData ??= new List<string>?[SectionNames.Length];
// If the section doesn't exist
if (index < 0 || index >= SectionTable.Length)
return null;
// If we already have cached data, just use that immediately
if (_sectionStringData[index] != null)
return _sectionStringData[index];