Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
go
Commits
4843b130
Commit
4843b130
authored
14 years ago
by
Russ Cox
Browse files
Options
Download
Email Patches
Plain Diff
runtime: avoid allocation for fixed strings
R=r CC=golang-dev
https://golang.org/cl/1083041
parent
d6b199ac
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
25 additions
and
14 deletions
+25
-14
src/pkg/runtime/darwin/386/signal.c
src/pkg/runtime/darwin/386/signal.c
+1
-1
src/pkg/runtime/darwin/amd64/signal.c
src/pkg/runtime/darwin/amd64/signal.c
+1
-1
src/pkg/runtime/freebsd/386/signal.c
src/pkg/runtime/freebsd/386/signal.c
+1
-1
src/pkg/runtime/freebsd/amd64/signal.c
src/pkg/runtime/freebsd/amd64/signal.c
+1
-1
src/pkg/runtime/iface.c
src/pkg/runtime/iface.c
+2
-2
src/pkg/runtime/linux/386/signal.c
src/pkg/runtime/linux/386/signal.c
+1
-1
src/pkg/runtime/linux/amd64/signal.c
src/pkg/runtime/linux/amd64/signal.c
+1
-1
src/pkg/runtime/linux/arm/signal.c
src/pkg/runtime/linux/arm/signal.c
+1
-1
src/pkg/runtime/runtime.c
src/pkg/runtime/runtime.c
+4
-4
src/pkg/runtime/runtime.h
src/pkg/runtime/runtime.h
+1
-0
src/pkg/runtime/string.goc
src/pkg/runtime/string.goc
+10
-0
src/pkg/runtime/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
...
...
This diff is collapsed.
Click to expand it.
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
...
...
This diff is collapsed.
Click to expand it.
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
...
...
This diff is collapsed.
Click to expand it.
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
...
...
This diff is collapsed.
Click to expand it.
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
);
}
...
...
This diff is collapsed.
Click to expand it.
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
...
...
This diff is collapsed.
Click to expand it.
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
...
...
This diff is collapsed.
Click to expand it.
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
...
...
This diff is collapsed.
Click to expand it.
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
);
}
...
...
This diff is collapsed.
Click to expand it.
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
);
...
...
This diff is collapsed.
Click to expand it.
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
)
{
...
...
This diff is collapsed.
Click to expand it.
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
);
...
...
This diff is collapsed.
Click to expand it.
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