Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
/coreclrPublic archive

DateTime.ToString() Fast Track for RFC1123#7891

Merged
Petermarcu merged 4 commits intodotnet:masterfromPetermarcu:DateTime
Oct 31, 2016
Merged

DateTime.ToString() Fast Track for RFC1123#7891

Petermarcu merged 4 commits intodotnet:masterfromPetermarcu:DateTime
Oct 31, 2016

Conversation

@Petermarcu
Copy link
Member

Addresses issuehttps://github.com/dotnet/coreclr/issues/7881 . I still need to complete full testing but it looks good so far.

@Petermarcu
Copy link
MemberAuthor

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

returnFastFormatRoundtrip(dateTime,offset);
}

if(format[0]=='r'||format[0]=='R'){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Switch statement overformat[0] is likely to generate better code.


internalstaticreadonlyDateTimeFormatInfoFormatInfo=CultureInfo.InvariantCulture.DateTimeFormat;
internalstaticreadonlystring[]AbbreviatedMonthNames=FormatInfo.AbbreviatedMonthNames;
internalstaticreadonlystring[]AbbreviatedDayNames=FormatInfo.AbbreviatedDayNames;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nit: these three fields should all probably be prefixed with "Invariant"

}


privatestaticvoidAppendTimeOfDay(StringBuilderresult,DateTimedateTime)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nit: the name should probably include format information, e.g. AppendHHmmssTimeOfDay, or something along those lines.

internalstaticstringFastFormatRfc1123(DateTimedateTime,TimeSpanoffset,DateTimeFormatInfodtfi)
{
// ddd, dd MMM yyyy HH:mm:ss GMT
StringBuilderresult=StringBuilderCache.Acquire();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe:

constintRfc1123Length=29;StringBuilderresult=StringBuilderCache.Acquire(Rfc123Length);

?

@Petermarcu
Copy link
MemberAuthor

Good feedback. I incorporated it all.

{
StringBuilderresult=StringBuilderCache.Acquire();
// yyyy-MM-ddTHH:mm:ss.fffffffK
constintroundTrimFormatLength=28;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nit: Trim => Trip


result.Append(InvariantAbbreviatedDayNames[(int)dateTime.DayOfWeek]);
result.Append(',');
result.Append(' ');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

you may append both in on append call .Append(", ");

case'o':
returnFastFormatRoundtrip(dateTime,offset);
case'R':
case'r':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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;

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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
Copy link
MemberAuthor

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

@Petermarcu
Copy link
MemberAuthor

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

@Petermarcu
Copy link
MemberAuthor

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

@tarekgh
Copy link
Member

LGTM.

@PetermarcuPetermarcu merged commit5c0d01c intodotnet:masterOct 31, 2016
@karelzkarelz modified the milestone:2.0.0Aug 28, 2017
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

3 more reviewers

@stephentoubstephentoubstephentoub left review comments

@jkotasjkotasjkotas left review comments

@tarekghtarekghtarekgh left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

2.0.0

Development

Successfully merging this pull request may close these issues.

6 participants

@Petermarcu@tarekgh@stephentoub@jkotas@karelz@dnfclas

[8]ページ先頭

©2009-2025 Movatter.jp