MCPcopy Create free account
hub / github.com/catboost/catboost / Write

Method Write

util/stream/buffered.cpp:181–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179 }
180
181 inline void Write(const void* buf, size_t len) {
182 if (len <= MemOut_.Avail()) {
183 /*
184 * fast path
185 */
186
187 MemOut_.Write(buf, len);
188 } else {
189 const size_t stored = Stored();
190 const size_t full_len = stored + len;
191 const size_t good_len = DownToBufferGranularity(full_len);
192 const size_t write_from_buf = good_len - stored;
193
194 using TPart = IOutputStream::TPart;
195
196 alignas(TPart) char data[2 * sizeof(TPart)];
197 TPart* parts = reinterpret_cast<TPart*>(data);
198 TPart* end = parts;
199
200 if (stored) {
201 new (end++) TPart(Buf(), stored);
202 }
203
204 if (write_from_buf) {
205 new (end++) TPart(buf, write_from_buf);
206 }
207
208 Slave_->Write(parts, end - parts);
209
210 // grow buffer only on full flushes
211 OnBufferExhausted();
212 Reset();
213
214 if (write_from_buf < len) {
215 MemOut_.Write((const char*)buf + write_from_buf, len - write_from_buf);
216 }
217 }
218 }
219
220 inline void Write(char c) {
221 if (Y_UNLIKELY(MemOut_.Avail() == 0)) {

Callers 4

NextMethod · 0.45
FlushMethod · 0.45
DoWriteMethod · 0.45
DoWriteCMethod · 0.45

Calls 2

ResetFunction · 0.50
AvailMethod · 0.45

Tested by

no test coverage detected