Avoid allocation.

This commit is contained in:
Nuno Cruces
2024-01-12 13:33:43 +00:00
parent 6b0c2c0554
commit 145bc228af
3 changed files with 13 additions and 10 deletions

View File

@@ -23,8 +23,9 @@ func stringOrTime(text string) driver.Value {
}
// Slow path.
var buf [len(time.RFC3339Nano)]byte
date, err := time.Parse(time.RFC3339Nano, text)
if err == nil && date.Format(time.RFC3339Nano) == text {
if err == nil && text == string(date.AppendFormat(buf[:0], time.RFC3339Nano)) {
return date
}
return text

View File

@@ -67,7 +67,7 @@ func Fuzz_stringOrTime_2(f *testing.F) {
if !v.Equal(date) {
t.Fatalf("did not round-trip: %v", date)
}
// Make with the same zone offset:
// With the same zone offset:
_, off1 := v.Zone()
_, off2 := date.Zone()
if off1 != off2 {

View File

@@ -23,7 +23,7 @@ https://sqlite.org/lang_aggfunc.html
- [x] `COVAR_SAMP(dependent, independent)`
- [x] `CORR(dependent, independent)`
## Linear regression
## Linear regression aggregates
- [X] `REGR_AVGX(dependent, independent)`
- [X] `REGR_AVGY(dependent, independent)`
@@ -35,11 +35,13 @@ https://sqlite.org/lang_aggfunc.html
- [X] `REGR_INTERCEPT(dependent, independent)`
- [X] `REGR_R2(dependent, independent)`
## Ordered set aggregates
## Set aggregates
- [ ] `CUME_DIST(value_list) WITHIN GROUP (ORDER BY sort_list)`
- [ ] `RANK(value_list) WITHIN GROUP (ORDER BY sort_list)`
- [ ] `DENSE_RANK(value_list) WITHIN GROUP (ORDER BY sort_list)`
- [ ] `PERCENT_RANK(value_list) WITHIN GROUP (ORDER BY sort_list)`
- [ ] `PERCENTILE_CONT(percentile) WITHIN GROUP (ORDER BY sort_list)`
- [ ] `PERCENTILE_DISC(percentile) WITHIN GROUP (ORDER BY sort_list)`
- [X] `CUME_DIST() OVER window`
- [X] `RANK() OVER window`
- [X] `DENSE_RANK() OVER window`
- [X] `PERCENT_RANK() OVER window`
- [ ] `PERCENTILE_CONT(percentile) OVER window`
- [ ] `PERCENTILE_DISC(percentile) OVER window`
https://sqlite.org/windowfunctions.html#builtins