Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions internal/gopher-lua/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,8 @@ func (rg *registry) checkSize(requiredSize int) { // +inline-start
} // +inline-end

func (rg *registry) resize(requiredSize int) { // +inline-start
newSize := requiredSize + rg.growBy // give some padding
if newSize > rg.maxSize {
newSize = rg.maxSize
}
// give some padding
newSize := min(requiredSize+rg.growBy, rg.maxSize)
if newSize < requiredSize {
rg.handler.registryOverflow()
return
Expand Down Expand Up @@ -1037,10 +1035,7 @@ func (ls *LState) initCallFrame(cf *callFrame) { // +inline-start
namedparam1 <- lbase
namedparam2
*/
nvarargs := nargs - np
if nvarargs < 0 {
nvarargs = 0
}
nvarargs := max(nargs-np, 0)

ls.reg.SetTop(cf.LocalBase + nargs + np)
for i := 0; i < np; i++ {
Expand Down Expand Up @@ -1149,10 +1144,7 @@ func (ls *LState) pushCallFrame(cf callFrame, fn LValue, meta bool) { // +inline
namedparam1 <- lbase
namedparam2
*/
nvarargs := nargs - np
if nvarargs < 0 {
nvarargs = 0
}
nvarargs := max(nargs-np, 0)

ls.reg.SetTop(cf.LocalBase + nargs + np)
for i := 0; i < np; i++ {
Expand Down
15 changes: 3 additions & 12 deletions internal/gopher-lua/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,10 +783,7 @@ func init() {
namedparam1 <- lbase
namedparam2
*/
nvarargs := nargs - np
if nvarargs < 0 {
nvarargs = 0
}
nvarargs := max(nargs-np, 0)

ls.reg.SetTop(cf.LocalBase + nargs + np)
for i := 0; i < np; i++ {
Expand Down Expand Up @@ -965,10 +962,7 @@ func init() {
namedparam1 <- lbase
namedparam2
*/
nvarargs := nargs - np
if nvarargs < 0 {
nvarargs = 0
}
nvarargs := max(nargs-np, 0)

ls.reg.SetTop(cf.LocalBase + nargs + np)
for i := 0; i < np; i++ {
Expand Down Expand Up @@ -1452,10 +1446,7 @@ func init() {
RA := lbase + A
B := int(inst & 0x1ff) //GETB
nparams := int(cf.Fn.Proto.NumParameters)
nvarargs := cf.NArgs - nparams
if nvarargs < 0 {
nvarargs = 0
}
nvarargs := max(cf.NArgs-nparams, 0)
nwant := B - 1
if B == 0 {
nwant = nvarargs
Expand Down
5 changes: 1 addition & 4 deletions server/core_leaderboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -846,10 +846,7 @@ func getLeaderboardRecordsHaystack(ctx context.Context, logger *zap.Logger, db *
if start < 0 || len(firstRecords) < secondLimit {
start = 0
}
end := start + limit
if end > numRecords {
end = numRecords
}
end := min(start+limit, numRecords)

if start > 0 {
// There was a previous result that was discarded, the prev_cursor should be set.
Expand Down