<commit_before>/**
 * See Copyright Notice in picrin.h
 */

#include <string.h>

#include "picrin.h"
#include "picrin/pair.h"
#include "picrin/vector.h"
#include "picrin/blob.h"
#include "picrin/string.h"

bool
pic_equal_p(pic_state *pic, pic_value x, pic_value y)
{
  enum pic_tt type;

  if (pic_eqv_p(x, y))
    return true;

  type = pic_type(x);
  if (type != pic_type(y))
    return false;
  switch (type) {
  case PIC_TT_PAIR:
    return pic_equal_p(pic, pic_car(pic, x), pic_car(pic, y))
      && pic_equal_p(pic, pic_cdr(pic, x), pic_cdr(pic, y));
  case PIC_TT_BLOB: {
    int i;
    struct pic_blob *v1 = pic_blob_ptr(x), *v2 = pic_blob_ptr(y);
    for(i = 0; i < v1->len; ++i){
      if(v1->data[i] != v2->data[i])
        return false;
    }
    return true;
  }
  case PIC_TT_VECTOR:{
    size_t i;
    struct pic_vector *v1 = pic_vec_ptr(x), *v2 = pic_vec_ptr(y);
    
    for(i = 0; i < v1->len; ++i){
      if(! pic_equal_p(pic, v1->data[i], v2->data[i]))
        return false;
    }
    return true;
  }
  case PIC_TT_STRING:
    return pic_strcmp(pic_str_ptr(x), pic_str_ptr(y)) == 0;
  default:
    return false;
  }<commit_msg>check length before compare contents<commit_after>/**
 * See Copyright Notice in picrin.h
 */

#include <string.h>

#include "picrin.h"
#include "picrin/pair.h"
#include "picrin/vector.h"
#include "picrin/blob.h"
#include "picrin/string.h"

bool
pic_equal_p(pic_state *pic, pic_value x, pic_value y)
{
  enum pic_tt type;

  if (pic_eqv_p(x, y))
    return true;

  type = pic_type(x);
  if (type != pic_type(y))
    return false;
  switch (type) {
  case PIC_TT_PAIR:
    return pic_equal_p(pic, pic_car(pic, x), pic_car(pic, y))
      && pic_equal_p(pic, pic_cdr(pic, x), pic_cdr(pic, y));
  case PIC_TT_BLOB: {
    int i;
    struct pic_blob *v1 = pic_blob_ptr(x), *v2 = pic_blob_ptr(y);
    if(v1->len != v2->len){
      return false;
    }
    for(i = 0; i < v1->len; ++i){
      if(v1->data[i] != v2->data[i])
        return false;
    }
    return true;
  }
  case PIC_TT_VECTOR:{
    size_t i;
    struct pic_vector *v1 = pic_vec_ptr(x), *v2 = pic_vec_ptr(y);
    
    if(v1->len != v2->len){
      return false;
    }
    for(i = 0; i < v1->len; ++i){
      if(! pic_equal_p(pic, v1->data[i], v2->data[i]))
        return false;
    }
    return true;
  }
  case PIC_TT_STRING:
    return pic_strcmp(pic_str_ptr(x), pic_str_ptr(y)) == 0;
  default:
    return false;
  }
{'fraction_non_alphanumeric': 0.16234033786567778, 'fraction_numerical': 0.012360939431396786, 'mean_word_length': 2.9738134206219313, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, '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': '4954079', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1049, 'n_words': 228}