Skip to content

Commit

Permalink
RuntimeResourceSet improvements (#44454)
Browse files Browse the repository at this point in the history
* RuntimeResourceSet improvements

- remove unnecessary base class calls to trim more of base type
- remove code paths which were never executed
- replaced nested locking with simple locks
- fix caching for case insensitive mode
- add tests for more code paths

* Move local caseInsensitiveTable initialisation

* Clean up unused code

* Revert "Clean up unused code"

It's actually used via reflection in System.Resources.Extensions
  • Loading branch information
marek-safar authored Nov 13, 2020
1 parent 85d2df8 commit 8692967
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,16 @@ namespace System.Resources
// default file format.
//

internal struct ResourceLocator
internal readonly struct ResourceLocator
{
internal object? _value; // Can be null.
internal int _dataPos;

internal ResourceLocator(int dataPos, object? value)
{
_dataPos = dataPos;
_value = value;
DataPosition = dataPos;
Value = value;
}

internal int DataPosition => _dataPos;

// Allows adding in profiling data in a future version, or a special
// resource profiling build. We could also use WeakReference.
internal object? Value
{
get => _value;
set => _value = value;
}
internal int DataPosition { get; }
internal object? Value { get; }

internal static bool CanCache(ResourceTypeCode value)
{
Expand Down Expand Up @@ -800,8 +790,12 @@ private void _ReadResources()
// Read RuntimeResourceSet header
// Do file version check
int version = _store.ReadInt32();
if (version != RuntimeResourceSet.Version && version != 1)
throw new ArgumentException(SR.Format(SR.Arg_ResourceFileUnsupportedVersion, RuntimeResourceSet.Version, version));

// File format version number
const int CurrentVersion = 2;

if (version != CurrentVersion && version != 1)
throw new ArgumentException(SR.Format(SR.Arg_ResourceFileUnsupportedVersion, CurrentVersion, version));
_version = version;

_numResources = _store.ReadInt32();
Expand Down
Loading

0 comments on commit 8692967

Please sign in to comment.