Make indents and newlines consistent [ci skip]

This commit is contained in:
Nobuyoshi Nakada 2022-07-27 14:06:51 +09:00
parent 464f73a5f0
commit 852ac26e83
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6

View File

@ -86,7 +86,8 @@ io_buffer_map_file(struct rb_io_buffer *data, int descriptor, size_t size, off_t
if (flags & RB_IO_BUFFER_PRIVATE) { if (flags & RB_IO_BUFFER_PRIVATE) {
access |= FILE_MAP_COPY; access |= FILE_MAP_COPY;
data->flags |= RB_IO_BUFFER_PRIVATE; data->flags |= RB_IO_BUFFER_PRIVATE;
} else { }
else {
// This buffer refers to external data. // This buffer refers to external data.
data->flags |= RB_IO_BUFFER_EXTERNAL; data->flags |= RB_IO_BUFFER_EXTERNAL;
} }
@ -186,7 +187,8 @@ io_buffer_initialize(struct rb_io_buffer *data, void *base, size_t size, enum rb
if (!base) { if (!base) {
rb_raise(rb_eIOBufferAllocationError, "Could not allocate buffer!"); rb_raise(rb_eIOBufferAllocationError, "Could not allocate buffer!");
} }
} else { }
else {
// Otherwise we don't do anything. // Otherwise we don't do anything.
return; return;
} }
@ -384,7 +386,8 @@ rb_io_buffer_type_for(VALUE klass, VALUE string)
}; };
return rb_ensure(io_buffer_for_yield_instance, (VALUE)&arguments, io_buffer_for_yield_instance_ensure, (VALUE)&arguments); return rb_ensure(io_buffer_for_yield_instance, (VALUE)&arguments, io_buffer_for_yield_instance_ensure, (VALUE)&arguments);
} else { }
else {
// This internally returns the source string if it's already frozen. // This internally returns the source string if it's already frozen.
string = rb_str_tmp_frozen_acquire(string); string = rb_str_tmp_frozen_acquire(string);
return io_buffer_for_make_instance(klass, string); return io_buffer_for_make_instance(klass, string);
@ -557,7 +560,8 @@ rb_io_buffer_initialize(int argc, VALUE *argv, VALUE self)
if (argc > 0) { if (argc > 0) {
size = RB_NUM2SIZE(argv[0]); size = RB_NUM2SIZE(argv[0]);
} else { }
else {
size = RUBY_IO_BUFFER_DEFAULT_SIZE; size = RUBY_IO_BUFFER_DEFAULT_SIZE;
} }
@ -682,7 +686,8 @@ io_buffer_hexdump(VALUE string, size_t width, char *base, size_t size, int first
if (first) { if (first) {
rb_str_catf(string, "0x%08" PRIxSIZE " ", offset); rb_str_catf(string, "0x%08" PRIxSIZE " ", offset);
first = 0; first = 0;
} else { }
else {
rb_str_catf(string, "\n0x%08" PRIxSIZE " ", offset); rb_str_catf(string, "\n0x%08" PRIxSIZE " ", offset);
} }
@ -1139,7 +1144,8 @@ rb_io_buffer_slice(VALUE self, VALUE _offset, VALUE _length)
return instance; return instance;
} }
int rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size) int
rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size)
{ {
struct rb_io_buffer *data = NULL; struct rb_io_buffer *data = NULL;
TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
@ -1665,7 +1671,8 @@ io_buffer_copy_from(struct rb_io_buffer *data, const void *source_base, size_t s
// The offset we copy into the buffer: // The offset we copy into the buffer:
if (argc >= 1) { if (argc >= 1) {
offset = NUM2SIZET(argv[0]); offset = NUM2SIZET(argv[0]);
} else { }
else {
offset = 0; offset = 0;
} }
@ -1676,14 +1683,16 @@ io_buffer_copy_from(struct rb_io_buffer *data, const void *source_base, size_t s
if (source_offset > source_size) { if (source_offset > source_size) {
rb_raise(rb_eArgError, "The given source offset is bigger than the source itself!"); rb_raise(rb_eArgError, "The given source offset is bigger than the source itself!");
} }
} else { }
else {
source_offset = 0; source_offset = 0;
} }
// The length we are going to copy: // The length we are going to copy:
if (argc >= 2 && !RB_NIL_P(argv[1])) { if (argc >= 2 && !RB_NIL_P(argv[1])) {
length = NUM2SIZET(argv[1]); length = NUM2SIZET(argv[1]);
} else { }
else {
// Default to the source offset -> source size: // Default to the source offset -> source size:
length = source_size - source_offset; length = source_size - source_offset;
} }
@ -1836,7 +1845,8 @@ io_buffer_get_string(int argc, VALUE *argv, VALUE self)
if (argc >= 2 && !RB_NIL_P(argv[1])) { if (argc >= 2 && !RB_NIL_P(argv[1])) {
length = NUM2SIZET(argv[1]); length = NUM2SIZET(argv[1]);
} else { }
else {
length = size - offset; length = size - offset;
} }
@ -1956,7 +1966,8 @@ io_buffer_clear(int argc, VALUE *argv, VALUE self)
size_t length; size_t length;
if (argc >= 3) { if (argc >= 3) {
length = NUM2SIZET(argv[2]); length = NUM2SIZET(argv[2]);
} else { }
else {
length = data->size - offset; length = data->size - offset;
} }
@ -1965,8 +1976,9 @@ io_buffer_clear(int argc, VALUE *argv, VALUE self)
return self; return self;
} }
static static size_t
size_t io_buffer_default_size(size_t page_size) { io_buffer_default_size(size_t page_size)
{
// Platform agnostic default size, based on empirical performance observation: // Platform agnostic default size, based on empirical performance observation:
const size_t platform_agnostic_default_size = 64*1024; const size_t platform_agnostic_default_size = 64*1024;