New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTime.ToString() Fast Track for RFC1123 #7891

Merged
merged 4 commits into from Oct 31, 2016

Conversation

Projects
None yet
6 participants
@Petermarcu
Member

Petermarcu commented Oct 30, 2016

Addresses issue #7881 . I still need to complete full testing but it looks good so far.

@Petermarcu

This comment has been minimized.

Show comment
Hide comment
@Petermarcu

Petermarcu Oct 30, 2016

Member

@tarekgh , I measured a more than 50% reduction in allocated bytes and 75% reduction in allocations.

Member

Petermarcu commented Oct 30, 2016

@tarekgh , I measured a more than 50% reduction in allocated bytes and 75% reduction in allocations.

@Petermarcu

This comment has been minimized.

Show comment
Hide comment
@Petermarcu

Petermarcu Oct 30, 2016

Member

Good feedback. I incorporated it all.

Member

Petermarcu commented Oct 30, 2016

Good feedback. I incorporated it all.

internal static string FastFormatRoundtrip(DateTime dateTime, TimeSpan offset)
{
StringBuilder result = StringBuilderCache.Acquire();
// yyyy-MM-ddTHH:mm:ss.fffffffK
const int roundTrimFormatLength = 28;

This comment has been minimized.

@stephentoub

stephentoub Oct 30, 2016

Member

Nit: Trim => Trip

@stephentoub

stephentoub Oct 30, 2016

Member

Nit: Trim => Trip

return FastFormatRoundtrip(dateTime, offset);
case 'R':
case 'r':

This comment has been minimized.

@tarekgh

tarekgh Oct 30, 2016

Member

I am seeing in the ExpandPredefinedFormat we have the following code, but it looks you don't handle that

            case 'r':
            case 'R':       // RFC 1123 Standard                    
                if (offset != NullOffset) {
                    // Convert to UTC invariants mean this will be in range
                    dateTime = dateTime - offset;
                }
                else if (dateTime.Kind == DateTimeKind.Local) {
                    InvalidFormatForLocal(format, dateTime);
                }
                dtfi = DateTimeFormatInfo.InvariantInfo;
                break;
@tarekgh

tarekgh Oct 30, 2016

Member

I am seeing in the ExpandPredefinedFormat we have the following code, but it looks you don't handle that

            case 'r':
            case 'R':       // RFC 1123 Standard                    
                if (offset != NullOffset) {
                    // Convert to UTC invariants mean this will be in range
                    dateTime = dateTime - offset;
                }
                else if (dateTime.Kind == DateTimeKind.Local) {
                    InvalidFormatForLocal(format, dateTime);
                }
                dtfi = DateTimeFormatInfo.InvariantInfo;
                break;

This comment has been minimized.

@Petermarcu

Petermarcu Oct 30, 2016

Member

Yeah, that is special handling for DateTimeOffset I need to apply. Do you know what InvalidFormatForLocal(...) is for and why it exists and is empty? MDA?

@Petermarcu

Petermarcu Oct 30, 2016

Member

Yeah, that is special handling for DateTimeOffset I need to apply. Do you know what InvalidFormatForLocal(...) is for and why it exists and is empty? MDA?

@Petermarcu

This comment has been minimized.

Show comment
Hide comment
@Petermarcu

Petermarcu Oct 30, 2016

Member

@dotnet-bot test Linux ARM Emulator Cross Debug Build please

Member

Petermarcu commented Oct 30, 2016

@dotnet-bot test Linux ARM Emulator Cross Debug Build please

@Petermarcu

This comment has been minimized.

Show comment
Hide comment
@Petermarcu

Petermarcu Oct 31, 2016

Member

@dotnet-bot test Linux ARM Emulator Cross Debug Build please

Member

Petermarcu commented Oct 31, 2016

@dotnet-bot test Linux ARM Emulator Cross Debug Build please

@Petermarcu

This comment has been minimized.

Show comment
Hide comment
@Petermarcu

Petermarcu Oct 31, 2016

Member

@tarekgh , does that last update look good and address your feedback?

Member

Petermarcu commented Oct 31, 2016

@tarekgh , does that last update look good and address your feedback?

@tarekgh

This comment has been minimized.

Show comment
Hide comment
@tarekgh

tarekgh Oct 31, 2016

Member

LGTM.

Member

tarekgh commented Oct 31, 2016

LGTM.

@Petermarcu Petermarcu merged commit 5c0d01c into dotnet:master Oct 31, 2016

14 checks passed

CentOS7.1 x64 Debug Build and Test Build finished.
Details
FreeBSD x64 Checked Build Build finished.
Details
Linux ARM Emulator Cross Debug Build Build finished.
Details
Linux ARM Emulator Cross Release Build Build finished.
Details
OSX x64 Checked Build and Test Build finished.
Details
Ubuntu x64 Checked Build and Test Build finished.
Details
Ubuntu x64 Formatting Build finished.
Details
Windows_NT arm Cross Debug Build Build finished.
Details
Windows_NT arm Cross Release Build Build finished.
Details
Windows_NT x64 Debug Build and Test Build finished.
Details
Windows_NT x64 Formatting Build finished.
Details
Windows_NT x64 Release Priority 1 Build and Test Build finished.
Details
Windows_NT x86 legacy_backend Checked Build and Test Build finished.
Details
Windows_NT x86 ryujit Checked Build and Test Build finished.
Details

@karelz karelz modified the milestone: 2.0.0 Aug 28, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment