Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
dbc4ac69
Commit
dbc4ac69
authored
Dec 16, 2015
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduce the slicegrow
parent
29752e25
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
input.go
context/input.go
+5
-3
tree.go
tree.go
+2
-1
No files found.
context/input.go
View file @
dbc4ac69
...
...
@@ -50,7 +50,8 @@ type BeegoInput struct {
// NewInput return BeegoInput generated by Context.
func
NewInput
()
*
BeegoInput
{
return
&
BeegoInput
{
pvalues
:
make
([]
string
,
maxParam
),
pnames
:
make
([]
string
,
0
,
maxParam
),
pvalues
:
make
([]
string
,
0
,
maxParam
),
data
:
make
(
map
[
interface
{}]
interface
{}),
}
}
...
...
@@ -60,6 +61,7 @@ func (input *BeegoInput) Reset(ctx *Context) {
input
.
Context
=
ctx
input
.
CruSession
=
nil
input
.
pnames
=
input
.
pnames
[
:
0
]
input
.
pvalues
=
input
.
pvalues
[
:
0
]
input
.
data
=
nil
input
.
RequestBody
=
[]
byte
{}
}
...
...
@@ -264,7 +266,7 @@ func (input *BeegoInput) ParamsLen() int {
// Param returns router param by a given key.
func
(
input
*
BeegoInput
)
Param
(
key
string
)
string
{
for
i
,
v
:=
range
input
.
pnames
{
if
v
==
key
{
if
v
==
key
&&
i
<=
len
(
input
.
pvalues
)
{
return
input
.
pvalues
[
i
]
}
}
...
...
@@ -273,7 +275,7 @@ func (input *BeegoInput) Param(key string) string {
// SetParam will set the param with key and value
func
(
input
*
BeegoInput
)
SetParam
(
key
,
val
string
)
{
input
.
pvalues
[
len
(
input
.
pnames
)]
=
val
input
.
pvalues
=
append
(
input
.
pvalues
,
val
)
input
.
pnames
=
append
(
input
.
pnames
,
key
)
}
...
...
tree.go
View file @
dbc4ac69
...
...
@@ -288,7 +288,8 @@ func (t *Tree) Match(pattern string, ctx *context.Context) (runObject interface{
if
len
(
pattern
)
==
0
||
pattern
[
0
]
!=
'/'
{
return
nil
}
return
t
.
match
(
pattern
,
nil
,
ctx
)
w
:=
make
([]
string
,
0
,
20
)
return
t
.
match
(
pattern
,
w
,
ctx
)
}
func
(
t
*
Tree
)
match
(
pattern
string
,
wildcardValues
[]
string
,
ctx
*
context
.
Context
)
(
runObject
interface
{})
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment