Skip to content

Commit

Permalink
[patch] refactor
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <kpango@vdaas.org>
  • Loading branch information
kpango committed Feb 8, 2022
1 parent 91828e5 commit 5f82ec0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func main() {

fmt.Printf("s1=%v\ns2=%v\ns3=%v\ns4=%v\n", s1, s2, s3, s4)

fmt.Printf("nanonow %v\nnow unixnano %v\nnow add unixnano%v\nnanonow + dur %v\nstring %v",
fmt.Printf("nanonow %v\nnow unixnano %v\nnow add unixnano%v\nnanonow + dur %v\nstring %v\n",
fastime.UnixNanoNow(),
fastime.Now().Unix(),
fastime.Now().Add(time.Second),
Expand Down
16 changes: 16 additions & 0 deletions example/result.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
s1=2022-02-08 22:37:21.754272 +0900 JST
s2=2022-02-08 22:37:21.754272 +0900 JST
s3=2022-02-08 22:37:21.754272 +0900 JST
s4=2022-02-08 22:37:23.755217 +0900 JST
nanonow 1644327448754453000
now unixnano 1644327448
now add unixnano2022-02-08 22:37:29.754453 +0900 JST
nanonow + dur 1644327449754453000
string 2022-02-08T22:37:28+09:00
Address of buf=fuckkkking: 0xc0001c8498
Address of buf=: 0xc0001c8498
Address of a1=[102 117 99 107 107 107 107 105 110 103]: 0xc000010350
Address of b1=fuckkkking: 0xc0001c84c8
Address of buf=helloooooo: 0xc0001c8498
Address of a2=[102 117 99 107 107 107 107 105 110 103]: 0xc000010380
Address of b2=fuckkkking: 0xc0001c84e0
3 changes: 2 additions & 1 deletion fastime.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ func (f *fastime) store(t time.Time) *fastime {
if buf == nil || len(form) > buf.Cap() {
buf.Grow(len(form))
}
f.ft.Store(t.AppendFormat(buf.Bytes()[:0], form))
f.ft.Store(t.AppendFormat(buf.Bytes(), form))
buf.Reset()
f.pool.Put(buf)
return f
}
Expand Down

0 comments on commit 5f82ec0

Please sign in to comment.