Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Mirror changes from dotnet/coreclr (#28384)
Browse files Browse the repository at this point in the history
* Small tweaks to Dict asm size (dotnet/coreclr#17096)

Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>

* Moving Span APIs that allow skipping visibility checks to MemoryMarshal (#17087)

Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>

* Improve DateTime{Offset} "r" and "o" formatting performance (#17092)

Two main changes:
1. Rewrote the formatting to use span, only to then discover that we already had almost exactly the same implementation in Utf8Formatter.  As that one had some extra optimizations around JIT behaviors, I ported that over instead.
2. Avoided [ThreadStatic] lookups unless necessary.

ToString/TryFormat for "o"/"O" improve by ~2.5x.

ToString/TryFormat for "r"/"R" improve by ~3x.

Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>

* Rename {Try}Read/WriteMachineEndian to just {Try}Read/Write (#17106)

Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>

* Fix incorrect array dereference. (dotnet/coreclr#17113)

Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>

* Move Span APIs that allow skipping visibility checks to MemoryMarshal

* Rename {Try}Read/WriteMachineEndian to just {Try}Read/Write

* Update calls to BinaryPrimitives.ReadMachineEndian

* Rename calls to ReadMachineEndian in System.Memory perf tests.

* Add ApiCompatBaseline for UWP NETNative

* Add to ApiCompatBaseline for UWP NETNative netstandard20
  • Loading branch information
dotnet-bot authored and ahsonkhan committed Mar 23, 2018
1 parent 9a72ba2 commit 3767d30
Show file tree
Hide file tree
Showing 30 changed files with 643 additions and 414 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ public void Clear()
_count = 0;
_freeList = -1;
_freeCount = 0;
_version++;
Array.Clear(_entries, 0, count);
}
_version++;
}

public bool ContainsKey(TKey key)
Expand Down Expand Up @@ -440,6 +440,7 @@ private bool TryInsert(TKey key, TValue value, InsertionBehavior behavior)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
}

_version++;
if (_buckets == null)
{
Initialize(0);
Expand Down Expand Up @@ -471,7 +472,6 @@ private bool TryInsert(TKey key, TValue value, InsertionBehavior behavior)
if (behavior == InsertionBehavior.OverwriteExisting)
{
entries[i].value = value;
_version++;
return true;
}

Expand Down Expand Up @@ -509,7 +509,6 @@ private bool TryInsert(TKey key, TValue value, InsertionBehavior behavior)
if (behavior == InsertionBehavior.OverwriteExisting)
{
entries[i].value = value;
_version++;
return true;
}

Expand Down Expand Up @@ -571,7 +570,6 @@ private bool TryInsert(TKey key, TValue value, InsertionBehavior behavior)
entry.value = value;
// Value in _buckets is 1-based
targetBucket = index + 1;
_version++;

// Value types never rehash
if (default(TKey) == null && collisionCount > HashHelpers.HashCollisionThreshold && comparer is NonRandomizedStringEqualityComparer)
Expand Down
18 changes: 9 additions & 9 deletions src/Common/src/CoreLib/System/DateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1255,46 +1255,46 @@ internal DateTime ToLocalTime(bool throwOnOverflow)

public String ToLongDateString()
{
return DateTimeFormat.Format(this, "D", DateTimeFormatInfo.CurrentInfo);
return DateTimeFormat.Format(this, "D", null);
}

public String ToLongTimeString()
{
return DateTimeFormat.Format(this, "T", DateTimeFormatInfo.CurrentInfo);
return DateTimeFormat.Format(this, "T", null);
}

public String ToShortDateString()
{
return DateTimeFormat.Format(this, "d", DateTimeFormatInfo.CurrentInfo);
return DateTimeFormat.Format(this, "d", null);
}

public String ToShortTimeString()
{
return DateTimeFormat.Format(this, "t", DateTimeFormatInfo.CurrentInfo);
return DateTimeFormat.Format(this, "t", null);
}

public override String ToString()
{
return DateTimeFormat.Format(this, null, DateTimeFormatInfo.CurrentInfo);
return DateTimeFormat.Format(this, null, null);
}

public String ToString(String format)
{
return DateTimeFormat.Format(this, format, DateTimeFormatInfo.CurrentInfo);
return DateTimeFormat.Format(this, format, null);
}

public String ToString(IFormatProvider provider)
{
return DateTimeFormat.Format(this, null, DateTimeFormatInfo.GetInstance(provider));
return DateTimeFormat.Format(this, null, provider);
}

public String ToString(String format, IFormatProvider provider)
{
return DateTimeFormat.Format(this, format, DateTimeFormatInfo.GetInstance(provider));
return DateTimeFormat.Format(this, format, provider);
}

public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider provider = null) =>
DateTimeFormat.TryFormat(this, destination, out charsWritten, format, DateTimeFormatInfo.GetInstance(provider));
DateTimeFormat.TryFormat(this, destination, out charsWritten, format, provider);

public DateTime ToUniversalTime()
{
Expand Down
10 changes: 5 additions & 5 deletions src/Common/src/CoreLib/System/DateTimeOffset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -755,26 +755,26 @@ internal DateTimeOffset ToLocalTime(bool throwOnOverflow)

public override String ToString()
{
return DateTimeFormat.Format(ClockDateTime, null, DateTimeFormatInfo.CurrentInfo, Offset);
return DateTimeFormat.Format(ClockDateTime, null, null, Offset);
}

public String ToString(String format)
{
return DateTimeFormat.Format(ClockDateTime, format, DateTimeFormatInfo.CurrentInfo, Offset);
return DateTimeFormat.Format(ClockDateTime, format, null, Offset);
}

public String ToString(IFormatProvider formatProvider)
{
return DateTimeFormat.Format(ClockDateTime, null, DateTimeFormatInfo.GetInstance(formatProvider), Offset);
return DateTimeFormat.Format(ClockDateTime, null, formatProvider, Offset);
}

public String ToString(String format, IFormatProvider formatProvider)
{
return DateTimeFormat.Format(ClockDateTime, format, DateTimeFormatInfo.GetInstance(formatProvider), Offset);
return DateTimeFormat.Format(ClockDateTime, format, formatProvider, Offset);
}

public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider formatProvider = null) =>
DateTimeFormat.TryFormat(ClockDateTime, destination, out charsWritten, format, DateTimeFormatInfo.GetInstance(formatProvider), Offset);
DateTimeFormat.TryFormat(ClockDateTime, destination, out charsWritten, format, formatProvider, Offset);

public DateTimeOffset ToUniversalTime()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ protected unsafe void WriteEvent(int eventId, string arg1, long arg2)
EventSource.EventData* descrs = stackalloc EventSource.EventData[2];
descrs[0].DataPointer = (IntPtr)string1Bytes;
descrs[0].Size = ((arg1.Length + 1) * 2);
descrs[1].Reserved = 0;
descrs[0].Reserved = 0;
descrs[1].DataPointer = (IntPtr)(&arg2);
descrs[1].Size = 8;
descrs[1].Reserved = 0;
Expand Down
Loading

0 comments on commit 3767d30

Please sign in to comment.