ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-Scalar/README
(Generate patch)

Comparing Convert-Scalar/README (file contents):
Revision 1.3 by root, Thu Jun 25 14:04:32 2015 UTC vs.
Revision 1.4 by root, Tue Aug 15 07:29:06 2017 UTC

98 current length is less than the new value. This does not affect the 98 current length is less than the new value. This does not affect the
99 contents of the scalar, but is only useful to "pre-allocate" memory 99 contents of the scalar, but is only useful to "pre-allocate" memory
100 space if you know the scalar will grow. The return value is the 100 space if you know the scalar will grow. The return value is the
101 modified scalar (the scalar is modified in-place). 101 modified scalar (the scalar is modified in-place).
102 102
103 scalar = extend scalar, addlen 103 scalar = extend scalar, addlen=64
104 Reserves enough space in the scalar so that addlen bytes can be 104 Reserves enough space in the scalar so that addlen bytes can be
105 appended without reallocating it. The actual contents of the scalar 105 appended without reallocating it. The actual contents of the scalar
106 will not be affected. The modified scalar will also be returned. 106 will not be affected. The modified scalar will also be returned.
107 107
108 This function is meant to make append workloads efficient - if you 108 This function is meant to make append workloads efficient - if you
112 112
113 If you instead use "extend $scalar, length $shortstring", then 113 If you instead use "extend $scalar, length $shortstring", then
114 Convert::Scalar will use a "size to next power of two, roughly" 114 Convert::Scalar will use a "size to next power of two, roughly"
115 algorithm, so as the scalar grows, perl will have to resize and copy 115 algorithm, so as the scalar grows, perl will have to resize and copy
116 it less and less often. 116 it less and less often.
117
118 nread = extend_read fh, scalar, addlen=64
119 Calls "extend scalar, addlen" to ensure some space is available,
120 then do the equivalent of "sysread" to the end, to try to fill the
121 extra space. Returns how many bytes have been read, 0 on EOF or
122 undef> on eror, just like "sysread".
123
124 This function is useful to implement many protocols where you read
125 some data, see if it is enough to decode, and if not, read some
126 more, where the naive or easy way of doing this would result in bad
127 performance.
128
129 nread = read_all fh, scalar, length
130 Tries to read "length" bytes into "scalar". Unlike "read" or
131 "sysread", it will try to read more bytes if not all bytes could be
132 read in one go (this is often called "xread" in C).
133
134 Returns the total nunmber of bytes read (normally "length", unless
135 an error or EOF occured), 0 on EOF and "undef" on errors.
136
137 nwritten = write_all fh, scalar
138 Like "readall", but for writes - the equivalent of the "xwrite"
139 function often seen in C.
117 140
118 refcnt scalar[, newrefcnt] 141 refcnt scalar[, newrefcnt]
119 Returns the current reference count of the given scalar and 142 Returns the current reference count of the given scalar and
120 optionally sets it to the given reference count. 143 optionally sets it to the given reference count.
121 144

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines