-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
chore: optimizes time variables. #1242
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1612,15 +1612,20 @@ func (tx *Transaction) generateResponseBodyError(err error) { | |
// setTimeVariables sets all the time variables | ||
func (tx *Transaction) setTimeVariables() { | ||
timestamp := time.Unix(0, tx.Timestamp) | ||
tx.variables.time.Set(timestamp.Format(time.TimeOnly)) | ||
tx.variables.timeDay.Set(strconv.Itoa(timestamp.Day())) | ||
tx.variables.timeEpoch.Set(strconv.FormatInt(timestamp.Unix(), 10)) | ||
tx.variables.timeHour.Set(strconv.Itoa(timestamp.Hour())) | ||
tx.variables.timeMin.Set(strconv.Itoa(timestamp.Minute())) | ||
tx.variables.timeSec.Set(strconv.Itoa(timestamp.Second())) | ||
|
||
timeOnly := timestamp.Format(time.TimeOnly) | ||
tx.variables.time.Set(timeOnly) | ||
tx.variables.timeHour.Set(timeOnly[0:2]) | ||
tx.variables.timeMin.Set(timeOnly[3:5]) | ||
tx.variables.timeSec.Set(timeOnly[6:8]) | ||
|
||
y, m, d := timestamp.Date() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
tx.variables.timeDay.Set(strconv.Itoa(d)) | ||
tx.variables.timeMon.Set(strconv.Itoa(int(m))) | ||
tx.variables.timeYear.Set(strconv.Itoa(y)) | ||
Comment on lines
+1624
to
+1626
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we save some cycles by converting at read time instead? Or the optimization it is negligible? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot convert at read time unless lazy collections. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can. Instead of doing Then, when reading, you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
tx.variables.timeWday.Set(strconv.Itoa(int(timestamp.Weekday()))) | ||
tx.variables.timeMon.Set(strconv.Itoa(int(timestamp.Month()))) | ||
tx.variables.timeYear.Set(strconv.Itoa(timestamp.Year())) | ||
} | ||
|
||
// TransactionVariables has pointers to all the variables of the transaction | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👅