Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
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
golang
Commits
4843b130
Commit
4843b130
authored
May 20, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime: avoid allocation for fixed strings
R=r CC=golang-dev
https://golang.org/cl/1083041
parent
d6b199ac
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
25 additions
and
14 deletions
+25
-14
signal.c
src/pkg/runtime/darwin/386/signal.c
+1
-1
signal.c
src/pkg/runtime/darwin/amd64/signal.c
+1
-1
signal.c
src/pkg/runtime/freebsd/386/signal.c
+1
-1
signal.c
src/pkg/runtime/freebsd/amd64/signal.c
+1
-1
iface.c
src/pkg/runtime/iface.c
+2
-2
signal.c
src/pkg/runtime/linux/386/signal.c
+1
-1
signal.c
src/pkg/runtime/linux/amd64/signal.c
+1
-1
signal.c
src/pkg/runtime/linux/arm/signal.c
+1
-1
runtime.c
src/pkg/runtime/runtime.c
+4
-4
runtime.h
src/pkg/runtime/runtime.h
+1
-0
string.goc
src/pkg/runtime/string.goc
+10
-0
symtab.c
src/pkg/runtime/symtab.c
+1
-1
No files found.
src/pkg/runtime/darwin/386/signal.c
View file @
4843b130
...
...
@@ -30,7 +30,7 @@ signame(int32 sig)
{
if
(
sig
<
0
||
sig
>=
NSIG
)
return
emptystring
;
return
gostring
((
byte
*
)
sigtab
[
sig
].
name
);
return
gostring
nocopy
((
byte
*
)
sigtab
[
sig
].
name
);
}
void
...
...
src/pkg/runtime/darwin/amd64/signal.c
View file @
4843b130
...
...
@@ -38,7 +38,7 @@ signame(int32 sig)
{
if
(
sig
<
0
||
sig
>=
NSIG
)
return
emptystring
;
return
gostring
((
byte
*
)
sigtab
[
sig
].
name
);
return
gostring
nocopy
((
byte
*
)
sigtab
[
sig
].
name
);
}
void
...
...
src/pkg/runtime/freebsd/386/signal.c
View file @
4843b130
...
...
@@ -41,7 +41,7 @@ signame(int32 sig)
{
if
(
sig
<
0
||
sig
>=
NSIG
)
return
emptystring
;
return
gostring
((
byte
*
)
sigtab
[
sig
].
name
);
return
gostring
nocopy
((
byte
*
)
sigtab
[
sig
].
name
);
}
void
...
...
src/pkg/runtime/freebsd/amd64/signal.c
View file @
4843b130
...
...
@@ -49,7 +49,7 @@ signame(int32 sig)
{
if
(
sig
<
0
||
sig
>=
NSIG
)
return
emptystring
;
return
gostring
((
byte
*
)
sigtab
[
sig
].
name
);
return
gostring
nocopy
((
byte
*
)
sigtab
[
sig
].
name
);
}
void
...
...
src/pkg/runtime/iface.c
View file @
4843b130
...
...
@@ -467,7 +467,7 @@ ifacehash1(void *data, Type *t)
if
(
algarray
[
alg
].
hash
==
nohash
)
{
// calling nohash will panic too,
// but we can print a better error.
·
newErrorString
(
catstring
(
gostring
((
byte
*
)
"hash of unhashable type "
),
*
t
->
string
),
&
err
);
·
newErrorString
(
catstring
(
gostring
nocopy
((
byte
*
)
"hash of unhashable type "
),
*
t
->
string
),
&
err
);
·
panic
(
err
);
}
if
(
wid
<=
sizeof
(
data
))
...
...
@@ -501,7 +501,7 @@ ifaceeq1(void *data1, void *data2, Type *t)
if
(
algarray
[
alg
].
equal
==
noequal
)
{
// calling noequal will panic too,
// but we can print a better error.
·
newErrorString
(
catstring
(
gostring
((
byte
*
)
"comparing uncomparable type "
),
*
t
->
string
),
&
err
);
·
newErrorString
(
catstring
(
gostring
nocopy
((
byte
*
)
"comparing uncomparable type "
),
*
t
->
string
),
&
err
);
·
panic
(
err
);
}
...
...
src/pkg/runtime/linux/386/signal.c
View file @
4843b130
...
...
@@ -38,7 +38,7 @@ signame(int32 sig)
{
if
(
sig
<
0
||
sig
>=
NSIG
)
return
emptystring
;
return
gostring
((
byte
*
)
sigtab
[
sig
].
name
);
return
gostring
nocopy
((
byte
*
)
sigtab
[
sig
].
name
);
}
void
...
...
src/pkg/runtime/linux/amd64/signal.c
View file @
4843b130
...
...
@@ -46,7 +46,7 @@ signame(int32 sig)
{
if
(
sig
<
0
||
sig
>=
NSIG
)
return
emptystring
;
return
gostring
((
byte
*
)
sigtab
[
sig
].
name
);
return
gostring
nocopy
((
byte
*
)
sigtab
[
sig
].
name
);
}
void
...
...
src/pkg/runtime/linux/arm/signal.c
View file @
4843b130
...
...
@@ -46,7 +46,7 @@ signame(int32 sig)
{
if
(
sig
<
0
||
sig
>=
NSIG
)
return
emptystring
;
return
gostring
((
byte
*
)
sigtab
[
sig
].
name
);
return
gostring
nocopy
((
byte
*
)
sigtab
[
sig
].
name
);
}
void
...
...
src/pkg/runtime/runtime.c
View file @
4843b130
...
...
@@ -79,7 +79,7 @@ panicstring(int8 *s)
{
Eface
err
;
·
newErrorString
(
gostring
((
byte
*
)
s
),
&
err
);
·
newErrorString
(
gostring
nocopy
((
byte
*
)
s
),
&
err
);
·
panic
(
err
);
}
...
...
@@ -161,13 +161,13 @@ goargs(void)
genvv
=
malloc
(
envc
*
sizeof
genvv
[
0
]);
for
(
i
=
0
;
i
<
argc
;
i
++
)
gargv
[
i
]
=
gostring
(
argv
[
i
]);
gargv
[
i
]
=
gostring
nocopy
(
argv
[
i
]);
os
·
Args
.
array
=
(
byte
*
)
gargv
;
os
·
Args
.
len
=
argc
;
os
·
Args
.
cap
=
argc
;
for
(
i
=
0
;
i
<
envc
;
i
++
)
genvv
[
i
]
=
gostring
(
argv
[
argc
+
1
+
i
]);
genvv
[
i
]
=
gostring
nocopy
(
argv
[
argc
+
1
+
i
]);
os
·
Envs
.
array
=
(
byte
*
)
genvv
;
os
·
Envs
.
len
=
envc
;
os
·
Envs
.
cap
=
envc
;
...
...
@@ -220,7 +220,7 @@ void
byte
*
p
;
p
=
getenv
(
"GOROOT"
);
out
=
gostring
(
p
);
out
=
gostring
nocopy
(
p
);
FLUSH
(
&
out
);
}
...
...
src/pkg/runtime/runtime.h
View file @
4843b130
...
...
@@ -387,6 +387,7 @@ void* mal(uintptr);
uint32
cmpstring
(
String
,
String
);
String
catstring
(
String
,
String
);
String
gostring
(
byte
*
);
String
gostringnocopy
(
byte
*
);
String
gostringw
(
uint16
*
);
void
initsig
(
void
);
int32
gotraceback
(
void
);
...
...
src/pkg/runtime/string.goc
View file @
4843b130
...
...
@@ -60,6 +60,16 @@ gostring(byte *str)
return
s
;
}
String
gostringnocopy
(
byte
*
str
)
{
String
s
;
s
.
str
=
str
;
s
.
len
=
findnull
(
str
);
return
s
;
}
String
gostringw
(
uint16
*
str
)
{
...
...
src/pkg/runtime/symtab.c
View file @
4843b130
...
...
@@ -106,7 +106,7 @@ dofunc(Sym *sym)
break
;
}
f
=
&
func
[
nfunc
++
];
f
->
name
=
gostring
(
sym
->
name
);
f
->
name
=
gostring
nocopy
(
sym
->
name
);
f
->
entry
=
sym
->
value
;
if
(
sym
->
symtype
==
'L'
||
sym
->
symtype
==
'l'
)
f
->
frame
=
-
sizeof
(
uintptr
);
...
...
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