1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 01:24:05 +08:00

opt matrix.go

This commit is contained in:
shylinux 2021-06-15 09:53:27 +08:00
parent a61acd37aa
commit 2b262d2e79
2 changed files with 41 additions and 30 deletions

View File

@ -167,36 +167,45 @@ func (mat *Matrix) Train(m *ice.Message, npage, nhash string, seed string) int {
}
}
add := func(s int, c byte, cb func(*State)) {
state := &State{}
if mat.mat[s][c] != nil {
*state = *mat.mat[s][c]
}
m.Debug("GET(%d,%d): %#v", s, c, state)
cb(state)
if state.next == 0 {
sn = append(sn, true)
state.next = len(mat.mat)
mat.mat = append(mat.mat, make(map[byte]*State))
} else {
sn[state.next] = true
}
mat.mat[s][c] = state
points = append(points, &Point{s, c})
m.Debug("SET(%d,%d): %#v", s, c, state)
}
for _, s := range ss {
for _, c := range cc {
state := &State{}
if mat.mat[s][c] != nil {
*state = *mat.mat[s][c]
}
m.Debug("GET(%d,%d): %#v", s, c, state)
switch flag {
case '+':
state.star = true
case '*':
state.star = true
sn[s] = true
case '?':
sn[s] = true
}
if state.next == 0 {
state.next = len(mat.mat)
mat.mat = append(mat.mat, make(map[byte]*State))
sn = append(sn, true)
} else {
sn[state.next] = true
}
mat.mat[s][c] = state
points = append(points, &Point{s, c})
m.Debug("SET(%d,%d): %#v", s, c, state)
add(s, c, func(state *State) {
switch flag {
case '+':
sn = append(sn, true)
state.next = len(mat.mat)
mat.mat = append(mat.mat, make(map[byte]*State))
for _, c := range cc {
add(state.next, c, func(state *State) { state.star = true })
}
case '*':
state.star = true
sn[s] = true
case '?':
sn[s] = true
}
})
}
}

View File

@ -123,8 +123,10 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon
// 请求参数
for k, v := range r.Form {
for i, p := range v {
v[i], _ = url.QueryUnescape(p)
if r.Header.Get(ContentType) != ContentJSON {
// for i, p := range v {
// // v[i], _ = url.QueryUnescape(p)
// }
}
if msg.Optionv(k, v); k == ice.MSG_SESSID {
RenderCookie(msg, v[0])