Reduce addr_of_mut usage in scanner macros

This commit is contained in:
David Tolnay 2022-07-23 00:41:43 -07:00
parent 3d30605f5b
commit c7752de455
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82

View file

@ -29,49 +29,40 @@ unsafe fn CACHE(parser: *mut yaml_parser_t, length: size_t) -> i32 {
} }
unsafe fn SKIP(parser: *mut yaml_parser_t) { unsafe fn SKIP(parser: *mut yaml_parser_t) {
let index = addr_of_mut!((*parser).mark.index); (*parser).mark.index = (*parser).mark.index.wrapping_add(1);
*index = (*index).wrapping_add(1); (*parser).mark.column = (*parser).mark.column.wrapping_add(1);
let column = addr_of_mut!((*parser).mark.column); (*parser).unread = (*parser).unread.wrapping_sub(1);
*column = (*column).wrapping_add(1); (*parser).buffer.pointer = (*parser)
let unread = addr_of_mut!((*parser).unread); .buffer
*unread = (*unread).wrapping_sub(1); .pointer
let pointer = addr_of_mut!((*parser).buffer.pointer); .wrapping_offset(WIDTH!((*parser).buffer) as isize);
*pointer = (*pointer).wrapping_offset(WIDTH!((*parser).buffer) as isize);
} }
unsafe fn SKIP_LINE(parser: *mut yaml_parser_t) { unsafe fn SKIP_LINE(parser: *mut yaml_parser_t) {
if IS_CRLF!((*parser).buffer) { if IS_CRLF!((*parser).buffer) {
let index = addr_of_mut!((*parser).mark.index); (*parser).mark.index = (*parser).mark.index.wrapping_add(2);
*index = (*index as libc::c_ulong).wrapping_add(2_u64) as size_t as size_t; (*parser).mark.column = 0;
(*parser).mark.column = 0_u64; (*parser).mark.line = (*parser).mark.line.wrapping_add(1);
let line = addr_of_mut!((*parser).mark.line); (*parser).unread = (*parser).unread.wrapping_sub(2);
*line = (*line).wrapping_add(1); (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(2);
let unread = addr_of_mut!((*parser).unread);
*unread = (*unread as libc::c_ulong).wrapping_sub(2_u64) as size_t as size_t;
let pointer = addr_of_mut!((*parser).buffer.pointer);
*pointer = (*pointer).wrapping_offset(2_isize);
} else if IS_BREAK!((*parser).buffer) { } else if IS_BREAK!((*parser).buffer) {
let index = addr_of_mut!((*parser).mark.index); (*parser).mark.index = (*parser).mark.index.wrapping_add(1);
*index = (*index).wrapping_add(1); (*parser).mark.column = 0;
(*parser).mark.column = 0_u64; (*parser).mark.line = (*parser).mark.line.wrapping_add(1);
let line = addr_of_mut!((*parser).mark.line); (*parser).unread = (*parser).unread.wrapping_sub(1);
*line = (*line).wrapping_add(1); (*parser).buffer.pointer = (*parser)
let unread = addr_of_mut!((*parser).unread); .buffer
*unread = (*unread).wrapping_sub(1); .pointer
let pointer = addr_of_mut!((*parser).buffer.pointer); .wrapping_offset(WIDTH!((*parser).buffer) as isize);
*pointer = (*pointer).wrapping_offset(WIDTH!((*parser).buffer) as isize);
}; };
} }
unsafe fn READ(parser: *mut yaml_parser_t, string: *mut yaml_string_t) -> i32 { unsafe fn READ(parser: *mut yaml_parser_t, string: *mut yaml_string_t) -> i32 {
if STRING_EXTEND!(parser, *string) != 0 { if STRING_EXTEND!(parser, *string) != 0 {
COPY!(*string, (*parser).buffer); COPY!(*string, (*parser).buffer);
let fresh160 = addr_of_mut!((*parser).mark.index); (*parser).mark.index = (*parser).mark.index.wrapping_add(1);
*fresh160 = (*fresh160).wrapping_add(1); (*parser).mark.column = (*parser).mark.column.wrapping_add(1);
let fresh161 = addr_of_mut!((*parser).mark.column); (*parser).unread = (*parser).unread.wrapping_sub(1);
*fresh161 = (*fresh161).wrapping_add(1);
let fresh162 = addr_of_mut!((*parser).unread);
*fresh162 = (*fresh162).wrapping_sub(1);
1_i32 1_i32
} else { } else {
0_i32 0_i32
@ -81,80 +72,47 @@ unsafe fn READ(parser: *mut yaml_parser_t, string: *mut yaml_string_t) -> i32 {
unsafe fn READ_LINE(parser: *mut yaml_parser_t, string: *mut yaml_string_t) -> i32 { unsafe fn READ_LINE(parser: *mut yaml_parser_t, string: *mut yaml_string_t) -> i32 {
if STRING_EXTEND!(parser, *string) != 0 { if STRING_EXTEND!(parser, *string) != 0 {
if CHECK_AT!((*parser).buffer, b'\r', 0) && CHECK_AT!((*parser).buffer, b'\n', 1) { if CHECK_AT!((*parser).buffer, b'\r', 0) && CHECK_AT!((*parser).buffer, b'\n', 1) {
let fresh484 = addr_of_mut!((*string).pointer); *(*string).pointer = b'\n';
let fresh485 = *fresh484; (*string).pointer = (*string).pointer.wrapping_offset(1);
*fresh484 = (*fresh484).wrapping_offset(1); (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(2);
*fresh485 = b'\n'; (*parser).mark.index = (*parser).mark.index.wrapping_add(2);
let fresh486 = addr_of_mut!((*parser).buffer.pointer); (*parser).mark.column = 0;
*fresh486 = (*fresh486).wrapping_offset(2_isize); (*parser).mark.line = (*parser).mark.line.wrapping_add(1);
let fresh487 = addr_of_mut!((*parser).mark.index); (*parser).unread = (*parser).unread.wrapping_sub(2);
*fresh487 = (*fresh487 as libc::c_ulong).wrapping_add(2_u64) as size_t as size_t;
(*parser).mark.column = 0_u64;
let fresh488 = addr_of_mut!((*parser).mark.line);
*fresh488 = (*fresh488).wrapping_add(1);
let fresh489 = addr_of_mut!((*parser).unread);
*fresh489 = (*fresh489 as libc::c_ulong).wrapping_sub(2_u64) as size_t as size_t;
} else if CHECK_AT!((*parser).buffer, b'\r', 0) || CHECK_AT!((*parser).buffer, b'\n', 0) { } else if CHECK_AT!((*parser).buffer, b'\r', 0) || CHECK_AT!((*parser).buffer, b'\n', 0) {
let fresh490 = addr_of_mut!((*string).pointer); *(*string).pointer = b'\n';
let fresh491 = *fresh490; (*string).pointer = (*string).pointer.wrapping_offset(1);
*fresh490 = (*fresh490).wrapping_offset(1); (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(1);
*fresh491 = b'\n'; (*parser).mark.index = (*parser).mark.index.wrapping_add(1);
let fresh492 = addr_of_mut!((*parser).buffer.pointer); (*parser).mark.column = 0;
*fresh492 = (*fresh492).wrapping_offset(1); (*parser).mark.line = (*parser).mark.line.wrapping_add(1);
let fresh493 = addr_of_mut!((*parser).mark.index); (*parser).unread = (*parser).unread.wrapping_sub(1);
*fresh493 = (*fresh493).wrapping_add(1);
(*parser).mark.column = 0_u64;
let fresh494 = addr_of_mut!((*parser).mark.line);
*fresh494 = (*fresh494).wrapping_add(1);
let fresh495 = addr_of_mut!((*parser).unread);
*fresh495 = (*fresh495).wrapping_sub(1);
} else if CHECK_AT!((*parser).buffer, b'\xC2', 0) && CHECK_AT!((*parser).buffer, b'\x85', 1) } else if CHECK_AT!((*parser).buffer, b'\xC2', 0) && CHECK_AT!((*parser).buffer, b'\x85', 1)
{ {
let fresh496 = addr_of_mut!((*string).pointer); *(*string).pointer = b'\n';
let fresh497 = *fresh496; (*string).pointer = (*string).pointer.wrapping_offset(1);
*fresh496 = (*fresh496).wrapping_offset(1); (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(2);
*fresh497 = b'\n'; (*parser).mark.index = (*parser).mark.index.wrapping_add(1);
let fresh498 = addr_of_mut!((*parser).buffer.pointer); (*parser).mark.column = 0;
*fresh498 = (*fresh498).wrapping_offset(2_isize); (*parser).mark.line = (*parser).mark.line.wrapping_add(1);
let fresh499 = addr_of_mut!((*parser).mark.index); (*parser).unread = (*parser).unread.wrapping_sub(1);
*fresh499 = (*fresh499).wrapping_add(1);
(*parser).mark.column = 0_u64;
let fresh500 = addr_of_mut!((*parser).mark.line);
*fresh500 = (*fresh500).wrapping_add(1);
let fresh501 = addr_of_mut!((*parser).unread);
*fresh501 = (*fresh501).wrapping_sub(1);
} else if CHECK_AT!((*parser).buffer, b'\xE2', 0) } else if CHECK_AT!((*parser).buffer, b'\xE2', 0)
&& CHECK_AT!((*parser).buffer, b'\x80', 1) && CHECK_AT!((*parser).buffer, b'\x80', 1)
&& (CHECK_AT!((*parser).buffer, b'\xA8', 2) || CHECK_AT!((*parser).buffer, b'\xA9', 2)) && (CHECK_AT!((*parser).buffer, b'\xA8', 2) || CHECK_AT!((*parser).buffer, b'\xA9', 2))
{ {
let fresh502 = addr_of_mut!((*parser).buffer.pointer); *(*string).pointer = *(*parser).buffer.pointer;
let fresh503 = *fresh502; (*string).pointer = (*string).pointer.wrapping_offset(1);
*fresh502 = (*fresh502).wrapping_offset(1); (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(1);
let fresh504 = addr_of_mut!((*string).pointer); *(*string).pointer = *(*parser).buffer.pointer;
let fresh505 = *fresh504; (*string).pointer = (*string).pointer.wrapping_offset(1);
*fresh504 = (*fresh504).wrapping_offset(1); (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(1);
*fresh505 = *fresh503; *(*string).pointer = *(*parser).buffer.pointer;
let fresh506 = addr_of_mut!((*parser).buffer.pointer); (*string).pointer = (*string).pointer.wrapping_offset(1);
let fresh507 = *fresh506; (*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(1);
*fresh506 = (*fresh506).wrapping_offset(1); (*parser).mark.index = (*parser).mark.index.wrapping_add(1);
let fresh508 = addr_of_mut!((*string).pointer); (*parser).mark.column = 0;
let fresh509 = *fresh508; (*parser).mark.line = (*parser).mark.line.wrapping_add(1);
*fresh508 = (*fresh508).wrapping_offset(1); (*parser).unread = (*parser).unread.wrapping_sub(1);
*fresh509 = *fresh507;
let fresh510 = addr_of_mut!((*parser).buffer.pointer);
let fresh511 = *fresh510;
*fresh510 = (*fresh510).wrapping_offset(1);
let fresh512 = addr_of_mut!((*string).pointer);
let fresh513 = *fresh512;
*fresh512 = (*fresh512).wrapping_offset(1);
*fresh513 = *fresh511;
let fresh514 = addr_of_mut!((*parser).mark.index);
*fresh514 = (*fresh514).wrapping_add(1);
(*parser).mark.column = 0_u64;
let fresh515 = addr_of_mut!((*parser).mark.line);
*fresh515 = (*fresh515).wrapping_add(1);
let fresh516 = addr_of_mut!((*parser).unread);
*fresh516 = (*fresh516).wrapping_sub(1);
}; };
1_i32 1_i32
} else { } else {