<commit_before>#include "mag3110.h"

mag3110::mag3110() {
  read_position = 0;
  write_position = 0;
  fill = 0;
}

mag3110::~mag3110() {}

byte mag3110::fastread(void){
  Wire.beginTransmission(MAG_ADDR); // transmit to device 0x0E
  Wire.write(MAG_X_REG);              // x MSB reg
  Wire.endTransmission();       // actually send
  delayMicroseconds(2); //needs at least 1.3us free time between start and stop
  byte response = Wire.requestFrom(MAG_ADDR, 6);
  if (response == 6){  // request 6 bytes, if we get them all, great, if not ignore
    x[write_position] = Wire.read() << 8; // receive the byte
    x[write_position] = x[write_position] | Wire.read(); // receive the byte
    y[write_position] = Wire.read() << 8; // receive the byte
    y[write_position] = y[write_position] | Wire.read(); // receive the byte
    z[write_position] = Wire.read() << 8; // receive the byte
    z[write_position] = z[write_position] | Wire.read(); // receive the byte
    write_position = (write_position + 1) % MAG_BUFFER_DEPTH;          // Move the write position into the next spot so its clearly ready
    fill ++;
    return 0;
  }
  else {
    return 1;
  }
}
<commit_msg>simplify the return on error path<commit_after>#include "mag3110.h"

mag3110::mag3110() {
  read_position = 0;
  write_position = 0;
  fill = 0;
}

mag3110::~mag3110() {}

byte mag3110::fastread(void){
  Wire.beginTransmission(MAG_ADDR); // transmit to device 0x0E
  Wire.write(MAG_X_REG);              // x MSB reg
  Wire.endTransmission();       // actually send
  delayMicroseconds(2); //needs at least 1.3us free time between start and stop

  if (Wire.requestFrom(MAG_ADDR, 6, true) != 6) return 1;
  x[write_position] = Wire.read() << 8; // receive the byte
  x[write_position] = x[write_position] | Wire.read(); // receive the byte
  y[write_position] = Wire.read() << 8; // receive the byte
  y[write_position] = y[write_position] | Wire.read(); // receive the byte
  z[write_position] = Wire.read() << 8; // receive the byte
  z[write_position] = z[write_position] | Wire.read(); // receive the byte
  write_position = (write_position + 1) % MAG_BUFFER_DEPTH;          // Move the write position into the next spot so its clearly ready
  fill ++;

  return 0;
}

{'fraction_non_alphanumeric': 0.1354723707664884, 'fraction_numerical': 0.03609625668449198, 'mean_word_length': 3.309021113243762, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2911920', 'n_tokens_mistral': 803, 'n_tokens_neox': 741, 'n_words': 214}