FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/benchmark/fast_buffer2.js at master · objcode/node · GitHub
objcode
/
node
Public
forked from
nodejs/node-v0.x-archive
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
node
/
benchmark
/
fast_buffer2.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (34 loc) · 1010 Bytes
Breadcrumbs
node
/
benchmark
/
fast_buffer2.js
Copy path
File metadata and controls
42 lines (34 loc) · 1010 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var
SlowBuffer
=
require
(
'buffer'
)
.
SlowBuffer
;
var
POOLSIZE
=
8
*
1024
;
var
pool
;
function
allocPool
(
)
{
pool
=
new
SlowBuffer
(
POOLSIZE
)
;
pool
.
used
=
0
;
}
function
FastBuffer
(
length
)
{
this
.
length
=
length
;
if
(
length
>
POOLSIZE
)
{
// Big buffer, just alloc one.
this
.
parent
=
new
Buffer
(
length
)
;
this
.
offset
=
0
;
}
else
{
// Small buffer.
if
(
!
pool
||
pool
.
length
-
pool
.
used
<
length
)
allocPool
(
)
;
this
.
parent
=
pool
;
this
.
offset
=
pool
.
used
;
pool
.
used
+=
length
;
}
// HERE HERE HERE
SlowBuffer
.
makeFastBuffer
(
this
.
parent
,
this
,
this
.
offset
,
this
.
length
)
;
}
exports
.
FastBuffer
=
FastBuffer
;
FastBuffer
.
prototype
.
get
=
function
(
i
)
{
if
(
i
<
0
||
i
>=
this
.
length
)
throw
new
Error
(
"oob"
)
;
return
this
.
parent
[
this
.
offset
+
i
]
;
}
;
FastBuffer
.
prototype
.
set
=
function
(
i
,
v
)
{
if
(
i
<
0
||
i
>=
this
.
length
)
throw
new
Error
(
"oob"
)
;
return
this
.
parent
[
this
.
offset
+
i
]
=
v
;
}
;
// TODO define slice, toString, write, etc.
// slice should not use c++
Back
|
FazBrowse Home
|
New Git URL