Skip to content

changed binary date / datetime to string #195

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

Merged
merged 3 commits into from
Dec 15, 2013

Conversation

arnehormann
Copy link
Member

Benchmark at https://gist.github.com/arnehormann/7930795 shows:
1 less allocation, speedup by factor 4+ for non-zero values

return []byte("0000-00-00"), nil
func formatBinaryDateTime(src []byte, withTime bool) (driver.Value, error) {
const zeroDateTimeMicros = "0000-00-00 00:00:00.000000"
srclen := len(src)
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to cache the length. The great thing about how slices and strings in Go are designed, is that getting the length is just reading an int64 - no indirection, no function calls: MOVQ src+8(FP),BX

Copy link
Member Author

Choose a reason for hiding this comment

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

I know. It reads smoother to me. But that's a bad habit, I'll change it.

@arnehormann
Copy link
Member Author

PTAL

@julienschmidt
Copy link
Member

LGTM, but it would be nice if we could optimize away the convT2E allocs someday.

@arnehormann
Copy link
Member Author

if you have an idea how to do it, I'm game :)

arnehormann added a commit that referenced this pull request Dec 15, 2013
changed binary date / datetime to string
@arnehormann arnehormann merged commit 948093a into go-sql-driver:master Dec 15, 2013
@arnehormann arnehormann deleted the faster-dateformat branch December 15, 2013 09:56
@julienschmidt julienschmidt added this to the v1.2 milestone Apr 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants