diff --git a/core/chromosome.cpp b/core/chromosome.cpp index 2492954c..7d6089b7 100644 --- a/core/chromosome.cpp +++ b/core/chromosome.cpp @@ -2041,8 +2041,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setAncestralNucleotides(EidosGlobalStrin else { // non-singleton, direct access - const EidosValue_Int_vector *int_vec = sequence_value->IntVector(); - const int64_t *int_data = int_vec->data(); + const int64_t *int_data = sequence_value->IntData(); ancestral_seq_buffer_ = new NucleotideArray(sequence_value_count, int_data); } @@ -2052,13 +2051,13 @@ EidosValue_SP Chromosome::ExecuteMethod_setAncestralNucleotides(EidosGlobalStrin if (sequence_value_count != 1) { // A vector of characters has been provided, which must all be "A" / "C" / "G" / "T" - const std::vector *string_vec = sequence_value->StringVector(); + const std::string *string_data = sequence_value->StringData(); - ancestral_seq_buffer_ = new NucleotideArray(sequence_value_count, *string_vec); + ancestral_seq_buffer_ = new NucleotideArray(sequence_value_count, string_data); } else // sequence_value_count == 1 { - const std::string &sequence_string = sequence_value->IsSingleton() ? ((EidosValue_String_singleton *)sequence_value)->StringValue() : (*sequence_value->StringVector())[0]; + const std::string &sequence_string = sequence_value->StringData()[0]; bool contains_only_nuc = true; // OK, we do a weird thing here. We want to try to construct a NucleotideArray diff --git a/core/community_eidos.cpp b/core/community_eidos.cpp index d9b6bfc9..93e2a212 100644 --- a/core/community_eidos.cpp +++ b/core/community_eidos.cpp @@ -417,7 +417,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) // variables case gID_tick: { - if (cached_value_tick_ && (((EidosValue_Int_singleton *)cached_value_tick_.get())->IntValue() != tick_)) + if (cached_value_tick_ && (cached_value_tick_->IntData()[0] != tick_)) cached_value_tick_.reset(); if (!cached_value_tick_) cached_value_tick_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tick_)); diff --git a/core/genome.cpp b/core/genome.cpp index 1f6011b8..ddfaa6f0 100644 --- a/core/genome.cpp +++ b/core/genome.cpp @@ -570,7 +570,7 @@ void Genome::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Genome *)(p_values[value_index]))->tag_value_ = source_data[value_index]; @@ -767,7 +767,7 @@ EidosValue_SP Genome::ExecuteMethod_Accelerated_containsMutations(EidosObject ** EidosValue_SP result(logical_result); int64_t result_index = 0; - EidosObject * const *mutations_data = mutations_value->ObjectElementVector()->data(); + EidosObject * const *mutations_data = mutations_value->ObjectData(); for (size_t element_index = 0; element_index < p_elements_size; ++element_index) { @@ -1181,7 +1181,7 @@ EidosValue_SP Genome::ExecuteMethod_nucleotides(EidosGlobalStringID p_method_id, else { // vector case: replace the appropriate element in char_value - std::vector *char_vec = ((EidosValue_String_vector *)(char_value.get()))->StringVector_Mutable(); + std::string &char_vec = char_value->StringData_Mutable()[0]; GenomeWalker walker(this); walker.MoveToPosition(start); @@ -1198,7 +1198,7 @@ EidosValue_SP Genome::ExecuteMethod_nucleotides(EidosGlobalStringID p_method_id, int8_t nuc = mut->nucleotide_; if (nuc != -1) - (*char_vec)[pos - start] = gSLiM_Nucleotides[nuc]; + char_vec[pos - start] = gSLiM_Nucleotides[nuc]; walker.NextMutation(); } diff --git a/core/individual.cpp b/core/individual.cpp index 73a305d8..201fd22c 100644 --- a/core/individual.cpp +++ b/core/individual.cpp @@ -1245,7 +1245,7 @@ void Individual::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p_va } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->tag_value_ = source_data[value_index]; @@ -1266,7 +1266,7 @@ void Individual::SetProperty_Accelerated_tagF(EidosObject **p_values, size_t p_v } else { - const double *source_data = p_source.FloatVector()->data(); + const double *source_data = p_source.FloatData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->tagF_value_ = source_data[value_index]; @@ -1277,9 +1277,11 @@ void Individual::SetProperty_Accelerated_tagL0(EidosObject **p_values, size_t p_ { s_any_individual_tagL_set_ = true; + const eidos_logical_t *source_data = p_source.LogicalData(); + if (p_source_size == 1) { - eidos_logical_t source_value = p_source.LogicalAtIndex(0, nullptr); + eidos_logical_t source_value = source_data[0]; for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1291,7 +1293,6 @@ void Individual::SetProperty_Accelerated_tagL0(EidosObject **p_values, size_t p_ } else { - const eidos_logical_t *source_data = p_source.LogicalVector()->data(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1307,9 +1308,11 @@ void Individual::SetProperty_Accelerated_tagL1(EidosObject **p_values, size_t p_ { s_any_individual_tagL_set_ = true; + const eidos_logical_t *source_data = p_source.LogicalData(); + if (p_source_size == 1) { - eidos_logical_t source_value = p_source.LogicalAtIndex(0, nullptr); + eidos_logical_t source_value = source_data[0]; for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1321,8 +1324,6 @@ void Individual::SetProperty_Accelerated_tagL1(EidosObject **p_values, size_t p_ } else { - const eidos_logical_t *source_data = p_source.LogicalVector()->data(); - for (size_t value_index = 0; value_index < p_values_size; ++value_index) { Individual *individual = ((Individual *)(p_values[value_index])); @@ -1337,9 +1338,11 @@ void Individual::SetProperty_Accelerated_tagL2(EidosObject **p_values, size_t p_ { s_any_individual_tagL_set_ = true; + const eidos_logical_t *source_data = p_source.LogicalData(); + if (p_source_size == 1) { - eidos_logical_t source_value = p_source.LogicalAtIndex(0, nullptr); + eidos_logical_t source_value = source_data[0]; for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1351,8 +1354,6 @@ void Individual::SetProperty_Accelerated_tagL2(EidosObject **p_values, size_t p_ } else { - const eidos_logical_t *source_data = p_source.LogicalVector()->data(); - for (size_t value_index = 0; value_index < p_values_size; ++value_index) { Individual *individual = ((Individual *)(p_values[value_index])); @@ -1367,9 +1368,11 @@ void Individual::SetProperty_Accelerated_tagL3(EidosObject **p_values, size_t p_ { s_any_individual_tagL_set_ = true; + const eidos_logical_t *source_data = p_source.LogicalData(); + if (p_source_size == 1) { - eidos_logical_t source_value = p_source.LogicalAtIndex(0, nullptr); + eidos_logical_t source_value = source_data[0]; for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1381,8 +1384,6 @@ void Individual::SetProperty_Accelerated_tagL3(EidosObject **p_values, size_t p_ } else { - const eidos_logical_t *source_data = p_source.LogicalVector()->data(); - for (size_t value_index = 0; value_index < p_values_size; ++value_index) { Individual *individual = ((Individual *)(p_values[value_index])); @@ -1397,9 +1398,11 @@ void Individual::SetProperty_Accelerated_tagL4(EidosObject **p_values, size_t p_ { s_any_individual_tagL_set_ = true; + const eidos_logical_t *source_data = p_source.LogicalData(); + if (p_source_size == 1) { - eidos_logical_t source_value = p_source.LogicalAtIndex(0, nullptr); + eidos_logical_t source_value = source_data[0]; for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1411,8 +1414,6 @@ void Individual::SetProperty_Accelerated_tagL4(EidosObject **p_values, size_t p_ } else { - const eidos_logical_t *source_data = p_source.LogicalVector()->data(); - for (size_t value_index = 0; value_index < p_values_size; ++value_index) { Individual *individual = ((Individual *)(p_values[value_index])); @@ -1478,7 +1479,7 @@ void Individual::SetProperty_Accelerated_fitnessScaling(EidosObject **p_values, } else { - const double *source_data = p_source.FloatVector()->data(); + const double *source_data = p_source.FloatData(); needs_raise = _SetFitnessScaling_N(source_data, p_values, p_values_size); } @@ -1498,7 +1499,7 @@ void Individual::SetProperty_Accelerated_x(EidosObject **p_values, size_t p_valu } else { - const double *source_data = p_source.FloatVector()->data(); + const double *source_data = p_source.FloatData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->spatial_x_ = source_data[value_index]; @@ -1516,7 +1517,7 @@ void Individual::SetProperty_Accelerated_y(EidosObject **p_values, size_t p_valu } else { - const double *source_data = p_source.FloatVector()->data(); + const double *source_data = p_source.FloatData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->spatial_y_ = source_data[value_index]; @@ -1534,7 +1535,7 @@ void Individual::SetProperty_Accelerated_z(EidosObject **p_values, size_t p_valu } else { - const double *source_data = p_source.FloatVector()->data(); + const double *source_data = p_source.FloatData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->spatial_z_ = source_data[value_index]; @@ -1573,12 +1574,12 @@ void Individual::SetProperty_Accelerated_color(EidosObject **p_values, size_t p_ } else { - const std::vector *source_data = p_source.StringVector(); + const std::string *source_data = p_source.StringData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { Individual *individual = ((Individual *)(p_values[value_index])); - const std::string &source_value = (*source_data)[value_index]; + const std::string &source_value = source_data[value_index]; if (source_value.empty()) { @@ -1606,7 +1607,7 @@ void Individual::SetProperty_Accelerated_age(EidosObject **p_values, size_t p_va } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->age_ = SLiMCastToAgeTypeOrRaise(source_data[value_index]); @@ -2282,8 +2283,7 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri } else if (target_size > 1) { - const EidosValue_Object_vector *target_vec = p_target->ObjectElementVector(); - Individual * const *targets = (Individual * const *)(target_vec->data()); + Individual * const *targets = (Individual * const *)(p_target->ObjectData()); dimensionality = targets[0]->subpopulation_->species_.SpatialDimensionality(); @@ -2333,8 +2333,7 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri else if (target_size > 1) { // Vector target case, one point - const EidosValue_Object_vector *target_vec = p_target->ObjectElementVector(); - Individual * const *targets = (Individual * const *)(target_vec->data()); + Individual * const *targets = (Individual * const *)(p_target->ObjectData()); switch (dimensionality) { @@ -2391,10 +2390,8 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri else if (value_count == dimensionality * target_size) { // Vector target case, one point per target (so the point vector has to be non-singleton too) - const EidosValue_Object_vector *target_vec = p_target->ObjectElementVector(); - Individual * const *targets = (Individual * const *)(target_vec->data()); - const EidosValue_Float_vector *position_vec = position_value->FloatVector(); - const double *positions = position_vec->data(); + Individual * const *targets = (Individual * const *)(p_target->ObjectData()); + const double *positions = position_value->FloatData(); #ifdef _OPENMP if (((dimensionality == 1) && (target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_2_1D)) || diff --git a/core/interaction_type.cpp b/core/interaction_type.cpp index 43178040..1424e732 100755 --- a/core/interaction_type.cpp +++ b/core/interaction_type.cpp @@ -3698,7 +3698,7 @@ EidosValue_SP InteractionType::ExecuteMethod_clippedIntegral(EidosGlobalStringID } else { - receivers_data = (Individual * const *)receivers_value->ObjectElementVector()->data(); + receivers_data = (Individual * const *)receivers_value->ObjectData(); } InteractionsData &receiver_subpop_data = InteractionsDataForSubpop(data_, receivers_data[0]->subpopulation_); @@ -6159,7 +6159,7 @@ EidosValue_SP InteractionType::ExecuteMethod_testConstraints(EidosGlobalStringID else { // non-singleton case - Individual * const *inds = (Individual * const *)individuals_value->ObjectElementVector()->data(); + Individual * const *inds = (Individual * const *)individuals_value->ObjectData(); if (returnIndividuals) { diff --git a/core/mutation.cpp b/core/mutation.cpp index f9f87306..2d9f049d 100644 --- a/core/mutation.cpp +++ b/core/mutation.cpp @@ -669,7 +669,7 @@ void Mutation::SetProperty_Accelerated_subpopID(EidosObject **p_values, size_t p } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Mutation *)(p_values[value_index]))->subpop_index_ = SLiMCastToObjectidTypeOrRaise(source_data[value_index]); @@ -688,7 +688,7 @@ void Mutation::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p_valu } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Mutation *)(p_values[value_index]))->tag_value_ = source_data[value_index]; diff --git a/core/mutation_type.cpp b/core/mutation_type.cpp index 723f97be..f75ffc34 100644 --- a/core/mutation_type.cpp +++ b/core/mutation_type.cpp @@ -688,7 +688,7 @@ void MutationType::SetProperty_Accelerated_convertToSubstitution(EidosObject **p } else { - const eidos_logical_t *source_data = p_source.LogicalVector()->data(); + const eidos_logical_t *source_data = p_source.LogicalData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((MutationType *)(p_values[value_index]))->convert_to_substitution_ = source_data[value_index]; @@ -707,7 +707,7 @@ void MutationType::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p_ } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((MutationType *)(p_values[value_index]))->tag_value_ = source_data[value_index]; diff --git a/core/population.cpp b/core/population.cpp index 0c25400e..880a3aa5 100644 --- a/core/population.cpp +++ b/core/population.cpp @@ -826,13 +826,8 @@ slim_popsize_t Population::ApplyMateChoiceCallbacks(slim_popsize_t p_parent1_ind weights_modified = true; } - // We really want to use EidosValue_Float_vector's FloatVector() method to get the values; - // if we have an EidosValue_Float_singleton we have to get its value with FloatAtIndex. - // BCH 1/18/2018: IsSingleton() should be much faster than the dynamic_cast<> used here before - if (!result->IsSingleton()) - memcpy(current_weights, ((EidosValue_Float_vector *)result)->FloatVector()->data(), sizeof(double) * weights_length); - else - current_weights[0] = result->FloatAtIndex(0, nullptr); + // use FloatData() to get the values, copy them with memcpy() + memcpy(current_weights, result->FloatData(), sizeof(double) * weights_length); // remember this callback for error attribution below last_interventionist_mate_choice_callback = mate_choice_callback; @@ -2512,8 +2507,7 @@ bool Population::ApplyRecombinationCallbacks(slim_popsize_t p_parent_index, Geno p_crossovers[0] = (slim_position_t)local_crossovers_ptr->IntAtIndex(0, nullptr); else { - const EidosValue_Int_vector *new_crossover_vector = local_crossovers_ptr->IntVector(); - const int64_t *new_crossover_data = new_crossover_vector->data(); + const int64_t *new_crossover_data = local_crossovers_ptr->IntData(); slim_position_t *p_crossovers_data = p_crossovers.data(); for (int value_index = 0; value_index < count; ++value_index) diff --git a/core/slim_eidos_block.cpp b/core/slim_eidos_block.cpp index 6c849d5a..324a2958 100644 --- a/core/slim_eidos_block.cpp +++ b/core/slim_eidos_block.cpp @@ -1731,7 +1731,7 @@ void SLiMTypeInterpreter::_SetTypeForISArgumentOfClass(const EidosASTNode *p_arg // The argument can be numeric, in which case it must have a cached int value that is singleton and within bounds EidosValue *cached_value = p_arg_node->cached_literal_value_.get(); - if (cached_value && (cached_value->Type() == EidosValueType::kValueInt) && (cached_value->IsSingleton())) + if (cached_value && (cached_value->Type() == EidosValueType::kValueInt) && (cached_value->Count() == 1)) { int64_t cached_int = cached_value->IntAtIndex(0, nullptr); diff --git a/core/slim_functions.cpp b/core/slim_functions.cpp index 2d5bb27e..beec1e43 100644 --- a/core/slim_functions.cpp +++ b/core/slim_functions.cpp @@ -610,7 +610,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorIntVector()->data(); + const int64_t *int_data = codons_value->IntData(); if (integer_result) { @@ -639,7 +639,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorAllocateChunk()) EidosValue_String_singleton("")); - std::string &aa_string = string_result->StringValue_Mutable(); + std::string &aa_string = string_result->StringData_Mutable()[0]; aa_string.resize(codons_length * 4 - 1); // create space for all the amino acids we will generate, including hyphens @@ -669,7 +669,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorAllocateChunk()) EidosValue_String_singleton("")); - std::string &aa_string = string_result->StringValue_Mutable(); + std::string &aa_string = string_result->StringData_Mutable()[0]; aa_string.resize(codons_length); // create space for all the amino acids we will generate @@ -726,7 +726,7 @@ EidosValue_SP SLiM_ExecuteFunction_nucleotidesToCodons(const std::vectorIsSingleton() ? ((EidosValue_String_singleton *)sequence_value)->StringValue() : (*sequence_value->StringVector())[0]; + const std::string &string_ref = sequence_value->StringData()[0]; int64_t length = (int64_t)string_ref.length(); if (length % 3 != 0) @@ -770,15 +770,15 @@ EidosValue_SP SLiM_ExecuteFunction_nucleotidesToCodons(const std::vector *string_vec = sequence_value->StringVector(); + const std::string *string_vec = sequence_value->StringData(); for (int value_index = 0; value_index < length_3; ++value_index) { int64_t codon_base = (size_t)value_index * 3; - const std::string &nucstring1 = (*string_vec)[codon_base]; - const std::string &nucstring2 = (*string_vec)[codon_base + 1]; - const std::string &nucstring3 = (*string_vec)[codon_base + 2]; + const std::string &nucstring1 = string_vec[codon_base]; + const std::string &nucstring2 = string_vec[codon_base + 1]; + const std::string &nucstring3 = string_vec[codon_base + 2]; if ((nucstring1.length() != 1) || (nucstring2.length() != 1) || (nucstring3.length() != 1)) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_nucleotidesToCodons): function nucleotidesToCodons() requires string sequence values to be 'A', 'C', 'G', or 'T'." << EidosTerminate(nullptr); @@ -798,7 +798,7 @@ EidosValue_SP SLiM_ExecuteFunction_nucleotidesToCodons(const std::vectorIntVector()->data(); + const int64_t *int_data = sequence_value->IntData(); for (int value_index = 0; value_index < length_3; ++value_index) { @@ -841,7 +841,7 @@ static void CountNucleotides(EidosValue *sequence_value, int64_t *total_ACGT, co else // sequence_type == EidosValueType::kValueString { uint8_t *nuc_lookup = NucleotideArray::NucleotideCharToIntLookup(); - const std::string &string_ref = sequence_value->IsSingleton() ? ((EidosValue_String_singleton *)sequence_value)->StringValue() : (*sequence_value->StringVector())[0]; + const std::string &string_ref = sequence_value->StringData()[0]; std::size_t length = string_ref.length(); for (std::size_t i = 0; i < length; ++i) @@ -861,7 +861,7 @@ static void CountNucleotides(EidosValue *sequence_value, int64_t *total_ACGT, co // Vector case, optimized for speed if (sequence_type == EidosValueType::kValueInt) { - const int64_t *int_data = sequence_value->IntVector()->data(); + const int64_t *int_data = sequence_value->IntData(); for (int value_index = 0; value_index < sequence_count; ++value_index) { @@ -876,11 +876,11 @@ static void CountNucleotides(EidosValue *sequence_value, int64_t *total_ACGT, co else // sequence_type == EidosValueType::kValueString { uint8_t *nuc_lookup = NucleotideArray::NucleotideCharToIntLookup(); - const std::vector *string_vec = sequence_value->StringVector(); + const std::string *string_vec = sequence_value->StringData(); for (int value_index = 0; value_index < sequence_count; ++value_index) { - const std::string &nuc_string = (*string_vec)[value_index]; + const std::string &nuc_string = string_vec[value_index]; if (nuc_string.length() != 1) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_" << function_name << "): function " << function_name << "() requires string sequence values to be 'A', 'C', 'G', or 'T'." << EidosTerminate(nullptr); @@ -1165,7 +1165,7 @@ EidosValue_SP SLiM_ExecuteFunction_randomNucleotides(const std::vectorAllocateChunk()) EidosValue_String_singleton("")); - std::string &nuc_string = string_result->StringValue_Mutable(); + std::string &nuc_string = string_result->StringData_Mutable()[0]; nuc_string.resize(length); // create space for all the nucleotides we will generate @@ -1269,7 +1269,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToNucleotides(const std::vectorAllocateChunk()) EidosValue_String_singleton("")); - std::string &nuc_string = string_result->StringValue_Mutable(); + std::string &nuc_string = string_result->StringData_Mutable()[0]; nuc_string.resize(length); // create space for all the nucleotides we will generate diff --git a/core/slim_globals.cpp b/core/slim_globals.cpp index b6484bf7..9bda0d46 100644 --- a/core/slim_globals.cpp +++ b/core/slim_globals.cpp @@ -780,7 +780,7 @@ NucleotideArray::NucleotideArray(std::size_t p_length, const char *p_char_buffer } } -NucleotideArray::NucleotideArray(std::size_t p_length, const std::vector &p_string_vector) : length_(p_length) +NucleotideArray::NucleotideArray(std::size_t p_length, const std::string p_string_vector[]) : length_(p_length) { buffer_ = (uint64_t *)malloc(((length_ + 31) / 32) * sizeof(uint64_t)); if (!buffer_) diff --git a/core/slim_globals.h b/core/slim_globals.h index 3405b2bf..5e61259a 100644 --- a/core/slim_globals.h +++ b/core/slim_globals.h @@ -662,7 +662,7 @@ class NucleotideArray // should therefore generally be called from a try/catch block. NucleotideArray(std::size_t p_length, const int64_t *p_int_buffer); NucleotideArray(std::size_t p_length, const char *p_char_buffer); - NucleotideArray(std::size_t p_length, const std::vector &p_string_vector); + NucleotideArray(std::size_t p_length, const std::string p_string_vector[]); std::size_t size() const { return length_; } diff --git a/core/spatial_map.cpp b/core/spatial_map.cpp index 75517947..89e95f9b 100644 --- a/core/spatial_map.cpp +++ b/core/spatial_map.cpp @@ -291,7 +291,7 @@ void SpatialMap::TakeColorsFromEidosValues(EidosValue *p_value_range, EidosValue if (!red_components_ || !green_components_ || !blue_components_) EIDOS_TERMINATION << "ERROR (" << p_code_name << "): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); - const std::string *colors_vec_ptr = p_colors->StringVector()->data(); + const std::string *colors_vec_ptr = p_colors->StringData(); for (int colors_index = 0; colors_index < n_colors_; ++colors_index) Eidos_GetColorComponents(colors_vec_ptr[colors_index], red_components_ + colors_index, green_components_ + colors_index, blue_components_ + colors_index); @@ -338,8 +338,8 @@ void SpatialMap::TakeValuesFromEidosValue(EidosValue *p_values, const std::strin EIDOS_TERMINATION << "ERROR (" << p_code_name << "): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); // Take the values we were passed in - const double *values_float_vec_ptr = (p_values->Type() == EidosValueType::kValueFloat) ? p_values->FloatVector()->data() : nullptr; - const int64_t *values_integer_vec_ptr = (p_values->Type() == EidosValueType::kValueInt) ? p_values->IntVector()->data() : nullptr; + const double *values_float_vec_ptr = (p_values->Type() == EidosValueType::kValueFloat) ? p_values->FloatData() : nullptr; + const int64_t *values_integer_vec_ptr = (p_values->Type() == EidosValueType::kValueInt) ? p_values->IntData() : nullptr; if (spatiality_ == 1) { @@ -2148,9 +2148,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_sampleImprovedNearbyPoint(EidosGlobalStr bool periodic = periodic_a_; // now guaranteed to apply to all dimensions - const EidosValue_Float_vector *point_vec = (point_count == 1) ? nullptr : point_value->FloatVector(); - double point_singleton = (point_count == 1) ? point_value->FloatAtIndex(0, nullptr) : 0.0; - const double *point_buf = (point_count == 1) ? &point_singleton : point_vec->data(); + const double *point_buf = point_value->FloatData(); const double *point_buf_ptr = point_buf; EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(point_count); @@ -2378,9 +2376,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_sampleNearbyPoint(EidosGlobalStringID p_ bool periodic = periodic_a_; // now guaranteed to apply to all dimensions - const EidosValue_Float_vector *point_vec = (point_count == 1) ? nullptr : point_value->FloatVector(); - double point_singleton = (point_count == 1) ? point_value->FloatAtIndex(0, nullptr) : 0.0; - const double *point_buf = (point_count == 1) ? &point_singleton : point_vec->data(); + const double *point_buf = point_value->FloatData(); const double *point_buf_ptr = point_buf; EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(point_count); diff --git a/core/species_eidos.cpp b/core/species_eidos.cpp index 1ff5809a..f86015b3 100644 --- a/core/species_eidos.cpp +++ b/core/species_eidos.cpp @@ -82,8 +82,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeAncestralNucleotides(con else { // non-singleton, direct access - const EidosValue_Int_vector *int_vec = sequence_value->IntVector(); - const int64_t *int_data = int_vec->data(); + const int64_t *int_data = sequence_value->IntData(); chromosome_->ancestral_seq_buffer_ = new NucleotideArray(sequence_value_count, int_data); } @@ -93,13 +92,13 @@ EidosValue_SP Species::ExecuteContextFunction_initializeAncestralNucleotides(con if (sequence_value_count != 1) { // A vector of characters has been provided, which must all be "A" / "C" / "G" / "T" - const std::vector *string_vec = sequence_value->StringVector(); + const std::string *string_data = sequence_value->StringData(); - chromosome_->ancestral_seq_buffer_ = new NucleotideArray(sequence_value_count, *string_vec); + chromosome_->ancestral_seq_buffer_ = new NucleotideArray(sequence_value_count, string_data); } else // sequence_value_count == 1 { - const std::string &sequence_string = sequence_value->IsSingleton() ? ((EidosValue_String_singleton *)sequence_value)->StringValue() : (*sequence_value->StringVector())[0]; + const std::string &sequence_string = sequence_value->StringData()[0]; bool contains_only_nuc = true; // OK, we do a weird thing here. We want to try to construct a NucleotideArray @@ -1623,7 +1622,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) } case gID_cycle: { - if (cached_value_cycle_ && (((EidosValue_Int_singleton *)cached_value_cycle_.get())->IntValue() != cycle_)) + if (cached_value_cycle_ && (cached_value_cycle_->IntData()[0] != cycle_)) cached_value_cycle_.reset(); if (!cached_value_cycle_) cached_value_cycle_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(cycle_)); @@ -1879,7 +1878,7 @@ EidosValue_SP Species::ExecuteMethod_individualsWithPedigreeIDs(EidosGlobalStrin else { // Non-singleton case: vectorized access to the pedigree IDs - const int64_t *pedigree_id_data = pedigreeIDs_value->IntVector()->data(); + const int64_t *pedigree_id_data = pedigreeIDs_value->IntData(); EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(pedigreeIDs_count); // reserve enough space for all results if (pedigreeIDs_count < 30) // crossover point determined by timing tests on macOS with various subpop sizes; 30 seems good, although it will vary across paltforms etc. @@ -3294,8 +3293,7 @@ EidosValue_SP Species::ExecuteMethod_treeSeqRememberIndividuals(EidosGlobalStrin } else { - const EidosValue_Object_vector *ind_vector = individuals_value->ObjectElementVector(); - EidosObject * const *oe_buffer = ind_vector->data(); + EidosObject * const *oe_buffer = individuals_value->ObjectData(); Individual * const *ind_buffer = (Individual * const *)oe_buffer; AddIndividualsToTable(ind_buffer, ind_count, &tables_, &tabled_individuals_hash_, flag); } diff --git a/core/subpopulation.cpp b/core/subpopulation.cpp index 839d7dad..d202b7d1 100644 --- a/core/subpopulation.cpp +++ b/core/subpopulation.cpp @@ -3897,14 +3897,13 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) else { // check that the cache is correct - EidosValue_Object_vector *vec = cached_child_genomes_value_->ObjectElementVector_Mutable(); - const std::vector *vec_direct = vec->ObjectElementVector(); - int vec_size = (int)vec_direct->size(); + const EidosObject * const *vec_direct = cached_child_genomes_value_->ObjectData(); + int vec_size = cached_child_genomes_value_->Count(); if (vec_size == (int)child_genomes_.size()) { for (int i = 0; i < vec_size; ++i) - if ((*vec_direct)[i] != &(child_genomes_[i])) + if (vec_direct[i] != child_genomes_[i]) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): value mismatch in cached_child_genomes_value_." << EidosTerminate(); } else @@ -3928,14 +3927,13 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) else { // check that the cache is correct - EidosValue_Object_vector *vec = cached_parent_genomes_value_->ObjectElementVector_Mutable(); - const std::vector *vec_direct = vec->ObjectElementVector(); - int vec_size = (int)vec_direct->size(); + const EidosObject * const *vec_direct = cached_parent_genomes_value_->ObjectData(); + int vec_size = cached_parent_genomes_value_->Count(); if (vec_size == (int)parent_genomes_.size()) { for (int i = 0; i < vec_size; ++i) - if ((*vec_direct)[i] != &(parent_genomes_[i])) + if (vec_direct[i] != parent_genomes_[i]) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): value mismatch in cached_parent_genomes_value_." << EidosTerminate(); } else @@ -4296,7 +4294,7 @@ void Subpopulation::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Subpopulation *)(p_values[value_index]))->tag_value_ = source_data[value_index]; @@ -4317,7 +4315,7 @@ void Subpopulation::SetProperty_Accelerated_fitnessScaling(EidosObject **p_value } else { - const double *source_data = p_source.FloatVector()->data(); + const double *source_data = p_source.FloatData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -5858,9 +5856,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointDeviated(EidosGlobalStringID p_m EidosValue *point_value = p_arguments[1].get(); int point_count = point_value->Count(); - const EidosValue_Float_vector *point_vec = (point_count == 1) ? nullptr : point_value->FloatVector(); - double point_singleton = (point_count == 1) ? point_value->FloatAtIndex(0, nullptr) : 0.0; - const double *point_buf = (point_count == 1) ? &point_singleton : point_vec->data(); + const double *point_buf = point_value->FloatData(); const double *point_buf_ptr = point_buf; if (point_count % dimensionality != 0) @@ -6220,8 +6216,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointInBounds(EidosGlobalStringID p_m return ((x >= bounds_x0_) && (x <= bounds_x1_)) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF; } - const EidosValue_Float_vector *float_vec = point_value->FloatVector(); - const double *point_buf = float_vec->data(); + const double *point_buf = point_value->FloatData(); if (point_count == 1) { @@ -6351,8 +6346,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointReflected(EidosGlobalStringID p_ } // non-singleton general case - const EidosValue_Float_vector *float_vec = point_value->FloatVector(); - const double *point_buf = float_vec->data(); + const double *point_buf = point_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(value_count); double *float_result_data = float_result->data(); @@ -6478,8 +6472,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointStopped(EidosGlobalStringID p_me } // non-singleton general case - const EidosValue_Float_vector *float_vec = point_value->FloatVector(); - const double *point_buf = float_vec->data(); + const double *point_buf = point_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(value_count); double *float_result_data = float_result->data(); @@ -6583,8 +6576,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointPeriodic(EidosGlobalStringID p_m } // non-singleton general case - const EidosValue_Float_vector *float_vec = point_value->FloatVector(); - const double *point_buf = float_vec->data(); + const double *point_buf = point_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(value_count); double *float_result_data = float_result->data(); diff --git a/eidos/eidos_class_Dictionary.cpp b/eidos/eidos_class_Dictionary.cpp index 93c0fd34..855f44c0 100644 --- a/eidos/eidos_class_Dictionary.cpp +++ b/eidos/eidos_class_Dictionary.cpp @@ -239,15 +239,13 @@ std::string EidosDictionaryUnretained::Serialization_SLiM(void) const // We want to output our keys in the same order as allKeys, so we just use AllKeys() EidosValue_SP all_keys = AllKeys(); - EidosValue_String_vector *string_vec = dynamic_cast(all_keys.get()); + int all_keys_count = all_keys->Count(); + const std::string *all_key_strings = all_keys->StringData(); - if (!string_vec) - EIDOS_TERMINATION << "ERROR (EidosDictionaryUnretained::Serialization_SLiM): (internal error) allKeys did not return a string vector." << EidosTerminate(nullptr); - - const std::vector *all_key_strings = string_vec->StringVector(); - - for (const std::string &key : *all_key_strings) + for (int key_index = 0; key_index < all_keys_count; ++key_index) { + const std::string key = all_key_strings[key_index]; + // emit the key; note that we now always quote stringkeys, to distinguish them from the integer-key case easily ss << Eidos_string_escaped(key, EidosStringQuoting::kDoubleQuotes) << "="; @@ -446,15 +444,13 @@ nlohmann::json EidosDictionaryUnretained::JSONRepresentation(void) const // We want to output our keys in the same order as allKeys, so we just use AllKeys() EidosValue_SP all_keys = AllKeys(); - EidosValue_String_vector *string_vec = dynamic_cast(all_keys.get()); + int all_keys_count = all_keys->Count(); + const std::string *all_key_strings = all_keys->StringData(); - if (!string_vec) - EIDOS_TERMINATION << "ERROR (EidosDictionaryUnretained::JSONRepresentation): (internal error) allKeys did not return a string vector." << EidosTerminate(nullptr); - - const std::vector *all_key_strings = string_vec->StringVector(); - - for (const std::string &key : *all_key_strings) + for (int key_index = 0; key_index < all_keys_count; ++key_index) { + const std::string key = all_key_strings[key_index]; + // get the value auto hash_iter = symbols->find(key); diff --git a/eidos/eidos_class_TestElement.cpp b/eidos/eidos_class_TestElement.cpp index 8c2782e7..1b58c0c8 100644 --- a/eidos/eidos_class_TestElement.cpp +++ b/eidos/eidos_class_TestElement.cpp @@ -116,7 +116,7 @@ void EidosTestElement::SetProperty_Accelerated__yolk(EidosObject **p_elements, s } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t element_index = 0; element_index < p_elements_size; ++element_index) ((EidosTestElement *)(p_elements[element_index]))->yolk_ = source_data[element_index]; diff --git a/eidos/eidos_functions.cpp b/eidos/eidos_functions.cpp index 5225ce4e..400738c1 100644 --- a/eidos/eidos_functions.cpp +++ b/eidos/eidos_functions.cpp @@ -440,8 +440,8 @@ bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compa // We have x_count != 1, so we can use the fast vector API; we want identical() to be very fast since it is a common bottleneck if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical_data0 = x_value->LogicalVector()->data(); - const eidos_logical_t *logical_data1 = y_value->LogicalVector()->data(); + const eidos_logical_t *logical_data0 = x_value->LogicalData(); + const eidos_logical_t *logical_data1 = y_value->LogicalData(); for (int value_index = 0; value_index < x_count; ++value_index) if (logical_data0[value_index] != logical_data1[value_index]) @@ -449,8 +449,8 @@ bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compa } else if (x_type == EidosValueType::kValueInt) { - const int64_t *int_data0 = x_value->IntVector()->data(); - const int64_t *int_data1 = y_value->IntVector()->data(); + const int64_t *int_data0 = x_value->IntData(); + const int64_t *int_data1 = y_value->IntData(); for (int value_index = 0; value_index < x_count; ++value_index) if (int_data0[value_index] != int_data1[value_index]) @@ -458,8 +458,8 @@ bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compa } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data0 = x_value->FloatVector()->data(); - const double *float_data1 = y_value->FloatVector()->data(); + const double *float_data0 = x_value->FloatData(); + const double *float_data1 = y_value->FloatData(); for (int value_index = 0; value_index < x_count; ++value_index) { @@ -473,8 +473,8 @@ bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compa } else if (x_type == EidosValueType::kValueString) { - const std::vector &string_vec0 = *x_value->StringVector(); - const std::vector &string_vec1 = *y_value->StringVector(); + const std::string *string_vec0 = x_value->StringData(); + const std::string *string_vec1 = y_value->StringData(); for (int value_index = 0; value_index < x_count; ++value_index) if (string_vec0[value_index] != string_vec1[value_index]) @@ -482,8 +482,8 @@ bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compa } else if (x_type == EidosValueType::kValueObject) { - EidosObject * const *objelement_vec0 = x_value->ObjectElementVector()->data(); - EidosObject * const *objelement_vec1 = y_value->ObjectElementVector()->data(); + EidosObject * const *objelement_vec0 = x_value->ObjectData(); + EidosObject * const *objelement_vec1 = y_value->ObjectData(); for (int value_index = 0; value_index < x_count; ++value_index) if (objelement_vec0[value_index] != objelement_vec1[value_index]) @@ -596,7 +596,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen if (arg_value_count) // weeds out NULL; otherwise we must have a logical vector { - const eidos_logical_t *arg_data = arg_value->LogicalVector()->data(); + const eidos_logical_t *arg_data = arg_value->LogicalData(); // Unlike the integer and float cases below, memcpy() is much faster for logical values // on OS X 10.12.6, Xcode 8.3; about 1.5 times faster, in fact. So it is a win here. @@ -631,7 +631,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen if (arg_value->Type() == EidosValueType::kValueInt) { // Speed up integer arguments, which are probably common since our result is integer - const int64_t *arg_data = arg_value->IntVector()->data(); + const int64_t *arg_data = arg_value->IntData(); // Annoyingly, memcpy() is actually *slower* here on OS X 10.12.6, Xcode 8.3; a test of the // memcpy() version runs in ~53.3 seconds versus ~48.4 seconds for the loop. So the Clang @@ -672,7 +672,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen if (arg_value->Type() == EidosValueType::kValueFloat) { // Speed up float arguments, which are probably common since our result is float - const double *arg_data = arg_value->FloatVector()->data(); + const double *arg_data = arg_value->FloatData(); // Annoyingly, memcpy() is actually *slower* here on OS X 10.12.6, Xcode 8.3; a test of the // memcpy() version runs in ~53.3 seconds versus ~48.4 seconds for the loop. So the Clang @@ -712,7 +712,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen if (arg_value->Type() == EidosValueType::kValueString) { // Speed up string arguments, which are probably common since our result is string - const std::vector &arg_vec = *arg_value->StringVector(); + const std::string *arg_vec = arg_value->StringData(); for (int value_index = 0; value_index < arg_value_count; ++value_index) result->PushString(arg_vec[value_index]); @@ -747,14 +747,13 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen } else if (arg_value_count) { - const EidosValue_Object_vector *object_arg_value = arg_value->ObjectElementVector(); - EidosObject * const *arg_data = object_arg_value->data(); + EidosObject * const *arg_data = arg_value->ObjectData(); // Given the lack of win for memcpy() for integer and float above, I'm not even going to bother checking it for // EidosObject*, since there would also be the complexity of retain/release and DeclareClass() to deal with... // When retain/release of EidosObject is enabled, we go through the accessors so the copied pointers get retained - if (object_arg_value->UsesRetainRelease()) + if (result->UsesRetainRelease()) { for (int value_index = 0; value_index < arg_value_count; ++value_index) result->set_object_element_no_check_no_previous_RR(arg_data[value_index], result_set_index++); @@ -798,7 +797,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec } else if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = x_value->LogicalData(); bool containsF = false, containsT = false; if (logical_data[0]) @@ -845,7 +844,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec else if (x_type == EidosValueType::kValueInt) { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); result_SP = EidosValue_SP(int_result); @@ -885,7 +884,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec else if (x_type == EidosValueType::kValueFloat) { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); result_SP = EidosValue_SP(float_result); @@ -930,7 +929,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec else if (x_type == EidosValueType::kValueString) { // We have x_count != 1, so the type of x_value must be EidosValue_String_vector; we can use the fast API - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); result_SP = EidosValue_SP(string_result); @@ -938,7 +937,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec { for (int value_index = 0; value_index < x_count; ++value_index) { - std::string value = string_vec[value_index]; + const std::string &value = string_vec[value_index]; int scan_index; for (scan_index = 0; scan_index < value_index; ++scan_index) @@ -953,8 +952,13 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec } else { - std::vector dup_vec = string_vec; + std::vector dup_vec; + + // first make a copy of string_vec into dup_vec + for (int value_index = 0; value_index < x_count; ++value_index) + dup_vec.push_back(string_vec[value_index]); + // then sort and unique std::sort(dup_vec.begin(), dup_vec.end()); auto unique_iter = std::unique(dup_vec.begin(), dup_vec.end()); @@ -966,7 +970,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec else if (x_type == EidosValueType::kValueObject) { // We have x_count != 1, so the type of x_value must be EidosValue_Object_vector; we can use the fast API - EidosObject * const *object_data = x_value->ObjectElementVector()->data(); + EidosObject * const *object_data = x_value->ObjectData(); EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); @@ -1040,7 +1044,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa } // Subsetting with a logical vector does not attempt to allocate singleton values, for now; seems unlikely to be a frequently hit case - const eidos_logical_t *logical_index_data = p_indices->LogicalVector()->data(); + const eidos_logical_t *logical_index_data = p_indices->LogicalData(); if (original_value_count == 1) { @@ -1058,7 +1062,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa // Here we can special-case each type for speed since we know we're not dealing with singletons if (original_value_type == EidosValueType::kValueLogical) { - const eidos_logical_t *first_child_data = p_original_value->LogicalVector()->data(); + const eidos_logical_t *first_child_data = p_original_value->LogicalData(); EidosValue_Logical_SP logical_result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); EidosValue_Logical *logical_result = logical_result_SP->reserve(indices_count); @@ -1070,7 +1074,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa } else if (original_value_type == EidosValueType::kValueInt) { - const int64_t *first_child_data = p_original_value->IntVector()->data(); + const int64_t *first_child_data = p_original_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->reserve(indices_count); @@ -1082,7 +1086,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa } else if (original_value_type == EidosValueType::kValueFloat) { - const double *first_child_data = p_original_value->FloatVector()->data(); + const double *first_child_data = p_original_value->FloatData(); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->reserve(indices_count); @@ -1094,7 +1098,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa } else if (original_value_type == EidosValueType::kValueString) { - const std::vector &first_child_vec = *p_original_value->StringVector(); + const std::string *first_child_vec = p_original_value->StringData(); EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); EidosValue_String_vector *string_result = string_result_SP->Reserve(indices_count); @@ -1106,7 +1110,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa } else if (original_value_type == EidosValueType::kValueObject) { - EidosObject * const *first_child_vec = p_original_value->ObjectElementVector()->data(); + EidosObject * const *first_child_vec = p_original_value->ObjectData(); EidosValue_Object_vector_SP obj_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)p_original_value)->Class())); EidosValue_Object_vector *obj_result = obj_result_SP->reserve(indices_count); @@ -1163,14 +1167,14 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa if (original_value_type == EidosValueType::kValueFloat) { // result type is float; optimize for that - const double *first_child_data = p_original_value->FloatVector()->data(); + const double *first_child_data = p_original_value->FloatData(); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->reserve(indices_count); if (indices_type == EidosValueType::kValueInt) { // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntVector()->data(); + const int64_t *int_index_data = p_indices->IntData(); for (int value_idx = 0; value_idx < indices_count; value_idx++) { @@ -1207,14 +1211,14 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueInt) { // result type is integer; optimize for that - const int64_t *first_child_data = p_original_value->IntVector()->data(); + const int64_t *first_child_data = p_original_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->reserve(indices_count); if (indices_type == EidosValueType::kValueInt) { // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntVector()->data(); + const int64_t *int_index_data = p_indices->IntData(); for (int value_idx = 0; value_idx < indices_count; value_idx++) { @@ -1251,14 +1255,14 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueObject) { // result type is object; optimize for that - EidosObject * const *first_child_vec = p_original_value->ObjectElementVector()->data(); + EidosObject * const *first_child_vec = p_original_value->ObjectData(); EidosValue_Object_vector_SP obj_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)p_original_value)->Class())); EidosValue_Object_vector *obj_result = obj_result_SP->reserve(indices_count); if (indices_type == EidosValueType::kValueInt) { // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntVector()->data(); + const int64_t *int_index_data = p_indices->IntData(); for (int value_idx = 0; value_idx < indices_count; value_idx++) { @@ -1295,14 +1299,14 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueLogical) { // result type is logical; optimize for that - const eidos_logical_t *first_child_data = p_original_value->LogicalVector()->data(); + const eidos_logical_t *first_child_data = p_original_value->LogicalData(); EidosValue_Logical_SP logical_result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); EidosValue_Logical *logical_result = logical_result_SP->reserve(indices_count); if (indices_type == EidosValueType::kValueInt) { // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntVector()->data(); + const int64_t *int_index_data = p_indices->IntData(); for (int value_idx = 0; value_idx < indices_count; value_idx++) { @@ -1339,14 +1343,14 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueString) { // result type is string; optimize for that - const std::vector &first_child_vec = *p_original_value->StringVector(); + const std::string *first_child_vec = p_original_value->StringData(); EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); EidosValue_String_vector *string_result = string_result_SP->Reserve(indices_count); if (indices_type == EidosValueType::kValueInt) { // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntVector()->data(); + const int64_t *int_index_data = p_indices->IntData(); for (int value_idx = 0; value_idx < indices_count; value_idx++) { diff --git a/eidos/eidos_functions_distributions.cpp b/eidos/eidos_functions_distributions.cpp index d3f81e13..89475272 100644 --- a/eidos/eidos_functions_distributions.cpp +++ b/eidos/eidos_functions_distributions.cpp @@ -86,7 +86,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorIsSingleton() ? &((EidosValue_Int_singleton *)arg_vec)->IntValue_Mutable() : ((EidosValue_Int_vector *)arg_vec)->data(); + const int64_t *vec_data = arg_vec->IntData(); // Check that vec is sorted for (int vec_index = 0; vec_index < vec_count - 1; ++vec_index) @@ -96,7 +96,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorIsSingleton() ? &((EidosValue_Int_singleton *)arg_x)->IntValue_Mutable() : ((EidosValue_Int_vector *)arg_x)->data(); + const int64_t *x_data = arg_x->IntData(); // Find intervals for integer vec, integer x @@ -143,7 +143,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorIsSingleton() ? &((EidosValue_Float_singleton *)arg_x)->FloatValue_Mutable() : ((EidosValue_Float_vector *)arg_x)->data(); + const double *x_data = arg_x->FloatData(); // Find intervals for integer vec, float x @@ -192,7 +192,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorIsSingleton() ? &((EidosValue_Float_singleton *)arg_vec)->FloatValue_Mutable() : ((EidosValue_Float_vector *)arg_vec)->data(); + const double *vec_data = arg_vec->FloatData(); // Check that vec is sorted for (int vec_index = 0; vec_index < vec_count - 1; ++vec_index) @@ -202,7 +202,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorIsSingleton() ? &((EidosValue_Int_singleton *)arg_x)->IntValue_Mutable() : ((EidosValue_Int_vector *)arg_x)->data(); + const int64_t *x_data = arg_x->IntData(); // Find intervals for float vec, integer x @@ -249,7 +249,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorIsSingleton() ? &((EidosValue_Float_singleton *)arg_x)->FloatValue_Mutable() : ((EidosValue_Float_vector *)arg_x)->data(); + const double *x_data = arg_x->FloatData(); // Find intervals for float vec, float x @@ -412,7 +412,7 @@ EidosValue_SP Eidos_ExecuteFunction_dmvnorm(const std::vector &p_ EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dmvnorm): (internal error) an unknown error with code " << gsl_err << " occurred inside the GNU Scientific Library's gsl_linalg_cholesky_decomp1() function." << EidosTerminate(nullptr); } - const double *float_data = arg_x->FloatVector()->data(); + const double *float_data = arg_x->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -486,7 +486,7 @@ EidosValue_SP Eidos_ExecuteFunction_dnorm(const std::vector &p_ar } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -498,7 +498,7 @@ EidosValue_SP Eidos_ExecuteFunction_dnorm(const std::vector &p_ar } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -566,7 +566,7 @@ EidosValue_SP Eidos_ExecuteFunction_qnorm(const std::vector &p_ar } else { - const double *float_data = arg_prob->FloatVector()->data(); + const double *float_data = arg_prob->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_probs); result_SP = EidosValue_SP(float_result); @@ -579,7 +579,7 @@ EidosValue_SP Eidos_ExecuteFunction_qnorm(const std::vector &p_ar } else { - const double *float_data = arg_prob->FloatVector()->data(); + const double *float_data = arg_prob->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_probs); result_SP = EidosValue_SP(float_result); @@ -636,7 +636,7 @@ EidosValue_SP Eidos_ExecuteFunction_pnorm(const std::vector &p_ar } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -646,7 +646,7 @@ EidosValue_SP Eidos_ExecuteFunction_pnorm(const std::vector &p_ar } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_quantiles); result_SP = EidosValue_SP(float_result); @@ -702,7 +702,7 @@ EidosValue_SP Eidos_ExecuteFunction_dbeta(const std::vector &p_ar } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -712,7 +712,7 @@ EidosValue_SP Eidos_ExecuteFunction_dbeta(const std::vector &p_ar } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -1129,7 +1129,7 @@ EidosValue_SP Eidos_ExecuteFunction_dexp(const std::vector &p_arg } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -1139,7 +1139,7 @@ EidosValue_SP Eidos_ExecuteFunction_dexp(const std::vector &p_arg } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -1325,7 +1325,7 @@ EidosValue_SP Eidos_ExecuteFunction_dgamma(const std::vector &p_a } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -1337,7 +1337,7 @@ EidosValue_SP Eidos_ExecuteFunction_dgamma(const std::vector &p_a } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); diff --git a/eidos/eidos_functions_files.cpp b/eidos/eidos_functions_files.cpp index 3bbe8a3f..b9f075b2 100644 --- a/eidos/eidos_functions_files.cpp +++ b/eidos/eidos_functions_files.cpp @@ -397,7 +397,7 @@ EidosValue_SP Eidos_ExecuteFunction_writeTempFile(const std::vector &string_vec = *contents_value->StringVector(); + const std::string *string_vec = contents_value->StringData(); for (int value_index = 0; value_index < contents_count; ++value_index) outstream << string_vec[value_index] << std::endl; @@ -458,7 +458,7 @@ EidosValue_SP Eidos_ExecuteFunction_writeTempFile(const std::vector &string_vec = *contents_value->StringVector(); + const std::string *string_vec = contents_value->StringData(); for (int value_index = 0; value_index < contents_count; ++value_index) { diff --git a/eidos/eidos_functions_math.cpp b/eidos/eidos_functions_math.cpp index 31dd7c5e..f1d724c7 100644 --- a/eidos/eidos_functions_math.cpp +++ b/eidos/eidos_functions_math.cpp @@ -78,7 +78,7 @@ EidosValue_SP Eidos_ExecuteFunction_abs(const std::vector &p_argu else { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -108,7 +108,7 @@ EidosValue_SP Eidos_ExecuteFunction_abs(const std::vector &p_argu else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -258,7 +258,7 @@ EidosValue_SP Eidos_ExecuteFunction_ceil(const std::vector &p_arg else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -318,7 +318,7 @@ EidosValue_SP Eidos_ExecuteFunction_cumProduct(const std::vector else { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); int64_t product = 1; EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -345,7 +345,7 @@ EidosValue_SP Eidos_ExecuteFunction_cumProduct(const std::vector else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); double product = 1.0; EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); @@ -381,7 +381,7 @@ EidosValue_SP Eidos_ExecuteFunction_cumSum(const std::vector &p_a else { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); int64_t sum = 0; EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -408,7 +408,7 @@ EidosValue_SP Eidos_ExecuteFunction_cumSum(const std::vector &p_a else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); double sum = 0.0; EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); @@ -449,7 +449,7 @@ EidosValue_SP Eidos_ExecuteFunction_exp(const std::vector &p_argu } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -480,7 +480,7 @@ EidosValue_SP Eidos_ExecuteFunction_floor(const std::vector &p_ar else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -528,8 +528,8 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector { if (x_count == y_count) { - const int64_t *int1_data = x_value->IntVector()->data(); - const int64_t *int2_data = y_value->IntVector()->data(); + const int64_t *int1_data = x_value->IntData(); + const int64_t *int2_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -547,7 +547,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector else if (x_count == 1) { int64_t int1 = x_value->IntAtIndex(0, nullptr); - const int64_t *int2_data = y_value->IntVector()->data(); + const int64_t *int2_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(y_count); result_SP = EidosValue_SP(int_result); @@ -563,7 +563,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector } else if (y_count == 1) { - const int64_t *int1_data = x_value->IntVector()->data(); + const int64_t *int1_data = x_value->IntData(); int64_t int2 = y_value->IntAtIndex(0, nullptr); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -629,8 +629,8 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector { if (x_count == y_count) { - const int64_t *int1_data = x_value->IntVector()->data(); - const int64_t *int2_data = y_value->IntVector()->data(); + const int64_t *int1_data = x_value->IntData(); + const int64_t *int2_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -648,7 +648,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector else if (x_count == 1) { int64_t int1 = x_value->IntAtIndex(0, nullptr); - const int64_t *int2_data = y_value->IntVector()->data(); + const int64_t *int2_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(y_count); result_SP = EidosValue_SP(int_result); @@ -664,7 +664,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector } else if (y_count == 1) { - const int64_t *int1_data = x_value->IntVector()->data(); + const int64_t *int1_data = x_value->IntData(); int64_t int2 = y_value->IntAtIndex(0, nullptr); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -716,7 +716,7 @@ EidosValue_SP Eidos_ExecuteFunction_isFinite(const std::vector &p else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -748,7 +748,7 @@ EidosValue_SP Eidos_ExecuteFunction_isInfinite(const std::vector else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -780,7 +780,7 @@ EidosValue_SP Eidos_ExecuteFunction_isNAN(const std::vector &p_ar else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -817,7 +817,7 @@ EidosValue_SP Eidos_ExecuteFunction_log(const std::vector &p_argu } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -856,7 +856,7 @@ EidosValue_SP Eidos_ExecuteFunction_log10(const std::vector &p_ar } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -895,7 +895,7 @@ EidosValue_SP Eidos_ExecuteFunction_log2(const std::vector &p_arg } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -929,7 +929,7 @@ EidosValue_SP Eidos_ExecuteFunction_product(const std::vector &p_ else { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); int64_t product = 1; double product_d = 1.0; bool fits_in_integer = true; @@ -971,7 +971,7 @@ EidosValue_SP Eidos_ExecuteFunction_product(const std::vector &p_ else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); double product = 1; for (int value_index = 0; value_index < x_count; ++value_index) @@ -999,7 +999,7 @@ EidosValue_SP Eidos_ExecuteFunction_round(const std::vector &p_ar else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -1061,9 +1061,9 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorLogicalVector()->data(); - const eidos_logical_t *logical_data1 = y_value->LogicalVector()->data(); + // both the singleton and non-singleton cases + const eidos_logical_t *logical_data0 = x_value->LogicalData(); + const eidos_logical_t *logical_data1 = y_value->LogicalData(); bool containsF0 = false, containsT0 = false, containsF1 = false, containsT1 = false; if (logical_data0[0]) @@ -1179,7 +1179,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorIntAtIndex(0, nullptr); - const int64_t *int_data = y_value->IntVector()->data(); + const int64_t *int_data = y_value->IntData(); for (int value_index = 0; value_index < y_count; ++value_index) if (int0 == int_data[value_index]) @@ -1190,7 +1190,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorFloatAtIndex(0, nullptr); - const double *float_data = y_value->FloatVector()->data(); + const double *float_data = y_value->FloatData(); for (int value_index = 0; value_index < y_count; ++value_index) { @@ -1205,7 +1205,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorStringRefAtIndex(0, nullptr); - const std::vector &string_vec = *y_value->StringVector(); + const std::string *string_vec = y_value->StringData(); for (int value_index = 0; value_index < y_count; ++value_index) if (string0 == string_vec[value_index]) @@ -1216,7 +1216,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectElementAtIndex(0, nullptr); - EidosObject * const *object_vec = y_value->ObjectElementVector()->data(); + EidosObject * const *object_vec = y_value->ObjectData(); for (int value_index = 0; value_index < y_count; ++value_index) if (obj0 == object_vec[value_index]) @@ -1235,7 +1235,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorIntAtIndex(0, nullptr); - EidosValue_Int_vector *int_vec = result_SP->IntVector_Mutable(); + EidosValue_Int_vector *int_vec = dynamic_cast(result_SP.get()); const int64_t *int_data = int_vec->data(); for (int value_index = 0; value_index < result_count; ++value_index) @@ -1248,8 +1248,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorFloatAtIndex(0, nullptr); - EidosValue_Float_vector *float_vec = result_SP->FloatVector_Mutable(); - double *float_data = float_vec->data(); + EidosValue_Float_vector *float_vec = dynamic_cast(result_SP.get()); + double *float_data = float_vec->FloatData_Mutable(); for (int value_index = 0; value_index < result_count; ++value_index) { @@ -1265,7 +1265,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorStringRefAtIndex(0, nullptr); - std::vector &string_vec = *result_SP->StringVector_Mutable(); + EidosValue_String_vector *string_vector_obj = dynamic_cast(result_SP.get()); + std::vector &string_vec = string_vector_obj->StringVectorData(); for (int value_index = 0; value_index < result_count; ++value_index) if (string1 == string_vec[value_index]) @@ -1277,7 +1278,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectElementAtIndex(0, nullptr); - EidosValue_Object_vector *object_element_vec = result_SP->ObjectElementVector_Mutable(); + EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); EidosObject * const *object_element_data = object_element_vec->data(); for (int value_index = 0; value_index < result_count; ++value_index) @@ -1293,8 +1294,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vector1, so we can use fast APIs for both if (x_type == EidosValueType::kValueInt) { - const int64_t *int_data0 = x_value->IntVector()->data(); - const int64_t *int_data1 = y_value->IntVector()->data(); + const int64_t *int_data0 = x_value->IntData(); + const int64_t *int_data1 = y_value->IntData(); EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); result_SP = EidosValue_SP(int_result); @@ -1324,8 +1325,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorFloatVector()->data(); - const double *float_data1 = y_value->FloatVector()->data(); + const double *float_data0 = x_value->FloatData(); + const double *float_data1 = y_value->FloatData(); EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); result_SP = EidosValue_SP(float_result); @@ -1363,8 +1364,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vector &string_vec0 = *x_value->StringVector(); - const std::vector &string_vec1 = *y_value->StringVector(); + const std::string *string_vec0 = x_value->StringData(); + const std::string *string_vec1 = y_value->StringData(); EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); result_SP = EidosValue_SP(string_result); @@ -1394,8 +1395,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectElementVector()->data(); - EidosObject * const *object_vec1 = y_value->ObjectElementVector()->data(); + EidosObject * const *object_vec0 = x_value->ObjectData(); + EidosObject * const *object_vec1 = y_value->ObjectData(); EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); @@ -1469,9 +1470,9 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorLogicalVector()->data(); - const eidos_logical_t *logical_data1 = y_value->LogicalVector()->data(); + // both the singleton and non-singleton cases + const eidos_logical_t *logical_data0 = x_value->LogicalData(); + const eidos_logical_t *logical_data1 = y_value->LogicalData(); bool containsF0 = false, containsT0 = false, containsF1 = false, containsT1 = false; if (logical_data0[0]) @@ -1591,7 +1592,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorIntAtIndex(0, nullptr); - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); for (int scan_index = 0; scan_index < x_count; ++scan_index) if (value == int_data[scan_index]) @@ -1603,7 +1604,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorFloatAtIndex(0, nullptr); - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); for (int scan_index = 0; scan_index < x_count; ++scan_index) { @@ -1619,7 +1620,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorStringRefAtIndex(0, nullptr); - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); for (int scan_index = 0; scan_index < x_count; ++scan_index) if (value == string_vec[scan_index]) @@ -1631,7 +1632,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorObjectElementAtIndex(0, nullptr); - EidosObject * const *object_vec = x_value->ObjectElementVector()->data(); + EidosObject * const *object_vec = x_value->ObjectData(); for (int scan_index = 0; scan_index < x_count; ++scan_index) if (value == object_vec[scan_index]) @@ -1651,8 +1652,8 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vector1, so we can use fast APIs for both if (x_type == EidosValueType::kValueInt) { - const int64_t *int_data0 = x_value->IntVector()->data(); - const int64_t *int_data1 = y_value->IntVector()->data(); + const int64_t *int_data0 = x_value->IntData(); + const int64_t *int_data1 = y_value->IntData(); EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); result_SP = EidosValue_SP(int_result); @@ -1681,8 +1682,8 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorFloatVector()->data(); - const double *float_data1 = y_value->FloatVector()->data(); + const double *float_data0 = x_value->FloatData(); + const double *float_data1 = y_value->FloatData(); EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); result_SP = EidosValue_SP(float_result); @@ -1717,8 +1718,8 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vector &string_vec0 = *x_value->StringVector(); - const std::vector &string_vec1 = *y_value->StringVector(); + const std::string *string_vec0 = x_value->StringData(); + const std::string *string_vec1 = y_value->StringData(); EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); result_SP = EidosValue_SP(string_result); @@ -1747,8 +1748,8 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorObjectElementVector()->data(); - EidosObject * const *object_vec1 = y_value->ObjectElementVector()->data(); + EidosObject * const *object_vec0 = x_value->ObjectData(); + EidosObject * const *object_vec1 = y_value->ObjectData(); EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); @@ -1836,9 +1837,9 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorLogicalVector()->data(); - const eidos_logical_t *logical_data1 = y_value->LogicalVector()->data(); + // both the singleton and non-singleton cases + const eidos_logical_t *logical_data0 = x_value->LogicalData(); + const eidos_logical_t *logical_data1 = y_value->LogicalData(); bool containsF0 = false, containsT0 = false, containsF1 = false, containsT1 = false; if (logical_data0[0]) @@ -1963,7 +1964,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorIntAtIndex(0, nullptr); - EidosValue_Int_vector *int_vec = result_SP->IntVector_Mutable(); + EidosValue_Int_vector *int_vec = dynamic_cast(result_SP.get()); const int64_t *int_data = int_vec->data(); int value_index; @@ -1979,8 +1980,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorFloatAtIndex(0, nullptr); - EidosValue_Float_vector *float_vec = result_SP->FloatVector_Mutable(); - double *float_data = float_vec->data(); + EidosValue_Float_vector *float_vec = dynamic_cast(result_SP.get()); + double *float_data = float_vec->FloatData_Mutable(); int value_index; for (value_index = 0; value_index < result_count; ++value_index) @@ -1999,7 +2000,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorStringRefAtIndex(0, nullptr); - std::vector &string_vec = *result_SP->StringVector_Mutable(); + EidosValue_String_vector *string_vector_obj = dynamic_cast(result_SP.get()); + std::vector &string_vec = string_vector_obj->StringVectorData(); int value_index; for (value_index = 0; value_index < result_count; ++value_index) @@ -2014,7 +2016,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorObjectElementAtIndex(0, nullptr); - EidosValue_Object_vector *object_element_vec = result_SP->ObjectElementVector_Mutable(); + EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); EidosObject * const *object_element_data = object_element_vec->data(); int value_index; @@ -2036,8 +2038,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorIntVector()->data(); - const int64_t *int_data1 = y_value->IntVector()->data(); + const int64_t *int_data0 = x_value->IntData(); + const int64_t *int_data1 = y_value->IntData(); EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); result_SP = EidosValue_SP(int_result); @@ -2085,8 +2087,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorFloatVector()->data(); - const double *float_vec1 = y_value->FloatVector()->data(); + const double *float_vec0 = x_value->FloatData(); + const double *float_vec1 = y_value->FloatData(); EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); result_SP = EidosValue_SP(float_result); @@ -2150,8 +2152,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vector &string_vec0 = *x_value->StringVector(); - const std::vector &string_vec1 = *y_value->StringVector(); + const std::string *string_vec0 = x_value->StringData(); + const std::string *string_vec1 = y_value->StringData(); EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); result_SP = EidosValue_SP(string_result); @@ -2199,8 +2201,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorObjectElementVector()->data(); - EidosObject * const *object_vec1 = y_value->ObjectElementVector()->data(); + EidosObject * const *object_vec0 = x_value->ObjectData(); + EidosObject * const *object_vec1 = y_value->ObjectData(); EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); @@ -2299,9 +2301,9 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p else if (arg_type == EidosValueType::kValueLogical) { // Because EidosValue_Logical works differently than other EidosValue types, this code can handle - // both the singleton and non-singleton cases; LogicalVector() is always available - const eidos_logical_t *logical_vec0 = x_value->LogicalVector()->data(); - const eidos_logical_t *logical_vec1 = y_value->LogicalVector()->data(); + // both the singleton and non-singleton cases + const eidos_logical_t *logical_vec0 = x_value->LogicalData(); + const eidos_logical_t *logical_vec1 = y_value->LogicalData(); bool containsF = false, containsT = false; if (((x_count > 0) && logical_vec0[0]) || ((y_count > 0) && logical_vec1[0])) @@ -2430,7 +2432,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p if (arg_type == EidosValueType::kValueInt) { int64_t value = y_value->IntAtIndex(0, nullptr); - const int64_t *int_data = result_SP->IntVector()->data(); + const int64_t *int_data = result_SP->IntData(); int scan_index; for (scan_index = 0; scan_index < result_count; ++scan_index) @@ -2440,12 +2442,16 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p } if (scan_index == result_count) - result_SP->IntVector_Mutable()->push_int(value); + { + EidosValue_Int_vector *int_vec = dynamic_cast(result_SP.get()); + + int_vec->push_int(value); + } } else if (arg_type == EidosValueType::kValueFloat) { double value1 = y_value->FloatAtIndex(0, nullptr); - const double *float_data = result_SP->FloatVector()->data(); + const double *float_data = result_SP->FloatData(); int scan_index; for (scan_index = 0; scan_index < result_count; ++scan_index) @@ -2457,37 +2463,50 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p } if (scan_index == result_count) - result_SP->FloatVector_Mutable()->push_float(value1); + { + EidosValue_Float_vector *float_vec = dynamic_cast(result_SP.get()); + + float_vec->push_float(value1); + } } else if (arg_type == EidosValueType::kValueString) { const std::string &value = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); - const std::vector &string_vec = *result_SP->StringVector(); + const std::string *string_data = result_SP->StringData(); int scan_index; for (scan_index = 0; scan_index < result_count; ++scan_index) { - if (value == string_vec[scan_index]) + if (value == string_data[scan_index]) break; } if (scan_index == result_count) - result_SP->StringVector_Mutable()->emplace_back(value); + { + EidosValue_String_vector *string_vector_obj = dynamic_cast(result_SP.get()); + std::vector &string_vec = string_vector_obj->StringVectorData(); + + string_vec.emplace_back(value); + } } else if (arg_type == EidosValueType::kValueObject) { EidosObject *value = y_value->ObjectElementAtIndex(0, nullptr); - EidosObject * const *object_vec = result_SP->ObjectElementVector()->data(); + EidosObject * const *object_data = result_SP->ObjectData(); int scan_index; for (scan_index = 0; scan_index < result_count; ++scan_index) { - if (value == object_vec[scan_index]) + if (value == object_data[scan_index]) break; } if (scan_index == result_count) - result_SP->ObjectElementVector_Mutable()->push_object_element_CRR(value); + { + EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); + + object_element_vec->push_object_element_CRR(value); + } } } else @@ -2552,7 +2571,7 @@ EidosValue_SP Eidos_ExecuteFunction_sqrt(const std::vector &p_arg } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -2588,7 +2607,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu #ifndef _OPENMP { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); int64_t sum = 0; double sum_d = 0; bool fits_in_integer = true; @@ -2624,7 +2643,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu { // In the OpenMP case we want to follow fairly different logic, because dealing with catching the overflow // case across multiple threads seems excessively complex; instead we look for an overflow afterwards - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); double sum_d = 0; EIDOS_THREAD_COUNT(gEidos_OMP_threads_SUM_INTEGER); @@ -2652,7 +2671,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); double sum = 0; EIDOS_THREAD_COUNT(gEidos_OMP_threads_SUM_FLOAT); @@ -2666,7 +2685,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu else if (x_type == EidosValueType::kValueLogical) { // EidosValue_Logical does not have a singleton subclass, so we can always use the fast API - const eidos_logical_t *logical_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = x_value->LogicalData(); int64_t sum = 0; EIDOS_THREAD_COUNT(gEidos_OMP_threads_SUM_LOGICAL); @@ -2695,7 +2714,7 @@ EidosValue_SP Eidos_ExecuteFunction_sumExact(const std::vector &p else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); double sum = Eidos_ExactSum(float_data, x_count); result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sum)); @@ -2745,7 +2764,7 @@ EidosValue_SP Eidos_ExecuteFunction_trunc(const std::vector &p_ar else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); diff --git a/eidos/eidos_functions_matrices.cpp b/eidos/eidos_functions_matrices.cpp index 0c003d06..514d867e 100644 --- a/eidos/eidos_functions_matrices.cpp +++ b/eidos/eidos_functions_matrices.cpp @@ -311,7 +311,7 @@ EidosValue_SP Eidos_ExecuteFunction_array(const std::vector &p_ar // construct the array from the data and dimensions result_SP = data_value->CopyValues(); - result_SP->SetDimensions(dim_count, dim_value->IntVector()->data()); + result_SP->SetDimensions(dim_count, dim_value->IntData()); return result_SP; } @@ -659,7 +659,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector if (x_type == EidosValueType::kValueInt) { int64_t x_singleton = x_value->IntAtIndex(0, nullptr); - const int64_t *y_data = y_value->IntVector()->data(); + const int64_t *y_data = y_value->IntData(); EidosValue_Int_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -678,7 +678,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector else // (x_type == EidosValueType::kValueFloat) { double x_singleton = x_value->FloatAtIndex(0, nullptr); - const double *y_data = y_value->FloatVector()->data(); + const double *y_data = y_value->FloatData(); EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -691,7 +691,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector // a column vector multiplied by a 1x1 vector if (x_type == EidosValueType::kValueInt) { - const int64_t *x_data = x_value->IntVector()->data(); + const int64_t *x_data = x_value->IntData(); int64_t y_singleton = y_value->IntAtIndex(0, nullptr); EidosValue_Int_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -710,7 +710,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector } else // (x_type == EidosValueType::kValueFloat) { - const double *x_data = x_value->FloatVector()->data(); + const double *x_data = x_value->FloatData(); double y_singleton = y_value->FloatAtIndex(0, nullptr); EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -724,8 +724,8 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector // this is the general case; we have non-singleton matrices for both x and y, so we can divide by integer/float and use direct access if (x_type == EidosValueType::kValueInt) { - const int64_t *x_data = x_value->IntVector()->data(); - const int64_t *y_data = y_value->IntVector()->data(); + const int64_t *x_data = x_value->IntData(); + const int64_t *y_data = y_value->IntData(); EidosValue_Int_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -767,8 +767,8 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector } else // (x_type == EidosValueType::kValueFloat) { - const double *x_data = x_value->FloatVector()->data(); - const double *y_data = y_value->FloatVector()->data(); + const double *x_data = x_value->FloatData(); + const double *y_data = y_value->FloatData(); EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); diff --git a/eidos/eidos_functions_other.cpp b/eidos/eidos_functions_other.cpp index 4745c5ff..9e238501 100644 --- a/eidos/eidos_functions_other.cpp +++ b/eidos/eidos_functions_other.cpp @@ -59,7 +59,7 @@ EidosValue_SP Eidos_ExecuteFunction_assert(const std::vector &p_a // determine whether the assertions vector is all true int assertions_count = assertions_value->Count(); - const eidos_logical_t *logical_data = assertions_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = assertions_value->LogicalData(); bool any_false = false; for (int assertions_index = 0; assertions_index < assertions_count; ++assertions_index) @@ -1468,7 +1468,7 @@ EidosValue_SP Eidos_ExecuteFunction_system(const std::vector &p_a } else { - const std::vector &string_vec = *input_value->StringVector(); + const std::string *string_vec = input_value->StringData(); for (int value_index = 0; value_index < input_count; ++value_index) { diff --git a/eidos/eidos_functions_stats.cpp b/eidos/eidos_functions_stats.cpp index 5341a369..f015ec17 100644 --- a/eidos/eidos_functions_stats.cpp +++ b/eidos/eidos_functions_stats.cpp @@ -46,7 +46,7 @@ EidosValue_SP Eidos_ExecuteFunction_cor(const std::vector &p_argu EidosValue *y_value = p_arguments[1].get(); int count = x_value->Count(); - if (x_value->IsArray() || y_value->IsArray()) + if (x_value->IsMatrixOrArray() || y_value->IsMatrixOrArray()) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_cor): function cor() does not currently support matrix/array arguments." << EidosTerminate(nullptr); if (count != y_value->Count()) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_cor): function cor() requires that x and y be the same size." << EidosTerminate(nullptr); @@ -100,7 +100,7 @@ EidosValue_SP Eidos_ExecuteFunction_cov(const std::vector &p_argu EidosValue *y_value = p_arguments[1].get(); int count = x_value->Count(); - if (x_value->IsArray() || y_value->IsArray()) + if (x_value->IsMatrixOrArray() || y_value->IsMatrixOrArray()) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_cov): function cov() does not currently support matrix/array arguments." << EidosTerminate(nullptr); if (count != y_value->Count()) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_cov): function cov() requires that x and y be the same size." << EidosTerminate(nullptr); @@ -186,20 +186,11 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu { EidosValue *arg_value = p_arguments[arg_index].get(); int arg_count = arg_value->Count(); + const eidos_logical_t *logical_data = arg_value->LogicalData(); - if (arg_count == 1) - { - if (arg_value->LogicalAtIndex(0, nullptr) == true) + for (int value_index = 0; value_index < arg_count; ++value_index) + if (logical_data[value_index] == true) return gStaticEidosValue_LogicalT; - } - else - { - const eidos_logical_t *logical_data = arg_value->LogicalVector()->data(); - - for (int value_index = 0; value_index < arg_count; ++value_index) - if (logical_data[value_index] == true) - return gStaticEidosValue_LogicalT; - } } result_SP = gStaticEidosValue_LogicalF; @@ -221,7 +212,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu } else if (arg_count > 1) { - const int64_t *int_data = arg_value->IntVector()->data(); + const int64_t *int_data = arg_value->IntData(); int64_t loop_max = INT64_MIN; EIDOS_THREAD_COUNT(gEidos_OMP_threads_MAX_INT); @@ -262,7 +253,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu } else { - const double *float_data = arg_value->FloatVector()->data(); + const double *float_data = arg_value->FloatData(); double loop_max = -std::numeric_limits::infinity(); bool saw_NAN = false; @@ -307,7 +298,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu } else { - const std::vector &string_vec = *arg_value->StringVector(); + const std::string *string_vec = arg_value->StringData(); for (int value_index = 0; value_index < arg_count; ++value_index) { @@ -401,20 +392,11 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu { EidosValue *arg_value = p_arguments[arg_index].get(); int arg_count = arg_value->Count(); + const eidos_logical_t *logical_data = arg_value->LogicalData(); - if (arg_count == 1) - { - if (arg_value->LogicalAtIndex(0, nullptr) == false) + for (int value_index = 0; value_index < arg_count; ++value_index) + if (logical_data[value_index] == false) return gStaticEidosValue_LogicalF; - } - else - { - const eidos_logical_t *logical_data = arg_value->LogicalVector()->data(); - - for (int value_index = 0; value_index < arg_count; ++value_index) - if (logical_data[value_index] == false) - return gStaticEidosValue_LogicalF; - } } result_SP = gStaticEidosValue_LogicalT; @@ -436,7 +418,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu } else if (arg_count > 1) { - const int64_t *int_data = arg_value->IntVector()->data(); + const int64_t *int_data = arg_value->IntData(); int64_t loop_min = INT64_MAX; EIDOS_THREAD_COUNT(gEidos_OMP_threads_MIN_INT); @@ -477,7 +459,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu } else { - const double *float_data = arg_value->FloatVector()->data(); + const double *float_data = arg_value->FloatData(); double loop_min = std::numeric_limits::infinity(); bool saw_NAN = false; @@ -522,7 +504,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu } else { - const std::vector &string_vec = *arg_value->StringVector(); + const std::string *string_vec = arg_value->StringData(); for (int value_index = 0; value_index < arg_count; ++value_index) { @@ -602,7 +584,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg // Then split up by type if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical0_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical0_data = x_value->LogicalData(); eidos_logical_t y_singleton_value = y_value->LogicalAtIndex(0, nullptr); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -612,7 +594,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg } else if (x_type == EidosValueType::kValueInt) { - const int64_t * __restrict__ int0_data = x_value->IntVector()->data(); + const int64_t * __restrict__ int0_data = x_value->IntData(); int64_t y_singleton_value = y_value->IntAtIndex(0, nullptr); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); @@ -638,7 +620,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg } else if (x_type == EidosValueType::kValueFloat) { - const double * __restrict__ float0_data = x_value->FloatVector()->data(); + const double * __restrict__ float0_data = x_value->FloatData(); double y_singleton_value = y_value->FloatAtIndex(0, nullptr); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); @@ -658,7 +640,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg } else if (x_type == EidosValueType::kValueString) { - const std::vector &string0_vec = *x_value->StringVector(); + const std::string *string0_vec = x_value->StringData(); const std::string &y_singleton_value = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); result_SP = EidosValue_SP(string_result); @@ -672,8 +654,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg // We know the type is not NULL or object, that x_count == y_count, and that they are not singletons; we split up by type and handle fast if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical0_data = x_value->LogicalVector()->data(); - const eidos_logical_t *logical1_data = y_value->LogicalVector()->data(); + const eidos_logical_t *logical0_data = x_value->LogicalData(); + const eidos_logical_t *logical1_data = y_value->LogicalData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -682,8 +664,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg } else if (x_type == EidosValueType::kValueInt) { - const int64_t * __restrict__ int0_data = x_value->IntVector()->data(); - const int64_t * __restrict__ int1_data = y_value->IntVector()->data(); + const int64_t * __restrict__ int0_data = x_value->IntData(); + const int64_t * __restrict__ int1_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -699,8 +681,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg } else if (x_type == EidosValueType::kValueFloat) { - const double * __restrict__ float0_data = x_value->FloatVector()->data(); - const double * __restrict__ float1_data = y_value->FloatVector()->data(); + const double * __restrict__ float0_data = x_value->FloatData(); + const double * __restrict__ float1_data = y_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -720,8 +702,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg } else if (x_type == EidosValueType::kValueString) { - const std::vector &string0_vec = *x_value->StringVector(); - const std::vector &string1_vec = *y_value->StringVector(); + const std::string *string0_vec = x_value->StringData(); + const std::string *string1_vec = y_value->StringData(); EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); result_SP = EidosValue_SP(string_result); @@ -800,7 +782,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg // Then split up by type if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical0_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical0_data = x_value->LogicalData(); eidos_logical_t y_singleton_value = y_value->LogicalAtIndex(0, nullptr); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -810,7 +792,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg } else if (x_type == EidosValueType::kValueInt) { - const int64_t * __restrict__ int0_data = x_value->IntVector()->data(); + const int64_t * __restrict__ int0_data = x_value->IntData(); int64_t y_singleton_value = y_value->IntAtIndex(0, nullptr); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); @@ -826,7 +808,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg } else if (x_type == EidosValueType::kValueFloat) { - const double * __restrict__ float0_data = x_value->FloatVector()->data(); + const double * __restrict__ float0_data = x_value->FloatData(); double y_singleton_value = y_value->FloatAtIndex(0, nullptr); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); @@ -846,7 +828,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg } else if (x_type == EidosValueType::kValueString) { - const std::vector &string0_vec = *x_value->StringVector(); + const std::string *string0_vec = x_value->StringData(); const std::string &y_singleton_value = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); result_SP = EidosValue_SP(string_result); @@ -860,8 +842,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg // We know the type is not NULL or object, that x_count == y_count, and that they are not singletons; we split up by type and handle fast if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical0_data = x_value->LogicalVector()->data(); - const eidos_logical_t *logical1_data = y_value->LogicalVector()->data(); + const eidos_logical_t *logical0_data = x_value->LogicalData(); + const eidos_logical_t *logical1_data = y_value->LogicalData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -870,8 +852,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg } else if (x_type == EidosValueType::kValueInt) { - const int64_t * __restrict__ int0_data = x_value->IntVector()->data(); - const int64_t * __restrict__ int1_data = y_value->IntVector()->data(); + const int64_t * __restrict__ int0_data = x_value->IntData(); + const int64_t * __restrict__ int1_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -887,8 +869,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg } else if (x_type == EidosValueType::kValueFloat) { - const double * __restrict__ float0_data = x_value->FloatVector()->data(); - const double * __restrict__ float1_data = y_value->FloatVector()->data(); + const double * __restrict__ float0_data = x_value->FloatData(); + const double * __restrict__ float1_data = y_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -908,8 +890,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg } else if (x_type == EidosValueType::kValueString) { - const std::vector &string0_vec = *x_value->StringVector(); - const std::vector &string1_vec = *y_value->StringVector(); + const std::string *string0_vec = x_value->StringData(); + const std::string *string1_vec = y_value->StringData(); EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); result_SP = EidosValue_SP(string_result); @@ -988,7 +970,7 @@ EidosValue_SP Eidos_ExecuteFunction_quantile(const std::vector &p if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); for (int value_index = 0; value_index < x_count; ++value_index) if (std::isnan(float_data[value_index])) @@ -999,9 +981,9 @@ EidosValue_SP Eidos_ExecuteFunction_quantile(const std::vector &p std::vector order; if (x_type == EidosValueType::kValueInt) - order = EidosSortIndexes(x_value->IntVector()->data(), x_count, true); + order = EidosSortIndexes(x_value->IntData(), x_count, true); else if (x_type == EidosValueType::kValueFloat) - order = EidosSortIndexes(x_value->FloatVector()->data(), x_count, true); + order = EidosSortIndexes(x_value->FloatData(), x_count, true); // Now loop over the requested probabilities and calculate them for (int probs_index = 0; probs_index < probs_count; ++probs_index) @@ -1087,7 +1069,7 @@ EidosValue_SP Eidos_ExecuteFunction_range(const std::vector &p_ar } else { - const int64_t *int_data = arg_value->IntVector()->data(); + const int64_t *int_data = arg_value->IntData(); for (int value_index = 0; value_index < arg_count; ++value_index) { @@ -1135,7 +1117,7 @@ EidosValue_SP Eidos_ExecuteFunction_range(const std::vector &p_ar } else { - const double *float_data = arg_value->FloatVector()->data(); + const double *float_data = arg_value->FloatData(); for (int value_index = 0; value_index < arg_count; ++value_index) { @@ -1223,7 +1205,7 @@ EidosValue_SP Eidos_ExecuteFunction_ttest(const std::vector &p_ar if (x_count <= 1) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_ttest): function ttest() requires enough elements in x to compute variance." << EidosTerminate(nullptr); - const double *vec1 = x_value->FloatVector()->data(); + const double *vec1 = x_value->FloatData(); double pvalue = 0.0; if (y_type != EidosValueType::kValueNULL) @@ -1232,7 +1214,7 @@ EidosValue_SP Eidos_ExecuteFunction_ttest(const std::vector &p_ar if (y_count <= 1) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_ttest): function ttest() requires enough elements in y to compute variance." << EidosTerminate(nullptr); - const double *vec2 = y_value->FloatVector()->data(); + const double *vec2 = y_value->FloatData(); // Right now this function only provides a two-sample t-test; we could add an optional mu argument and make y optional in order to allow a one-sample test as well // If we got into that, we'd probably want to provide one-sided t-tests as well, yada yada... @@ -1259,7 +1241,7 @@ EidosValue_SP Eidos_ExecuteFunction_var(const std::vector &p_argu EidosValue *x_value = p_arguments[0].get(); int x_count = x_value->Count(); - if (x_value->IsArray()) + if (x_value->IsMatrixOrArray()) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_var): function var() does not currently support a matrix/array argument." << EidosTerminate(nullptr); if (x_count > 1) diff --git a/eidos/eidos_functions_strings.cpp b/eidos/eidos_functions_strings.cpp index 7c8111bd..51162cbe 100644 --- a/eidos/eidos_functions_strings.cpp +++ b/eidos/eidos_functions_strings.cpp @@ -234,7 +234,7 @@ EidosValue_SP Eidos_ExecuteFunction_nchar(const std::vector &p_ar } else { - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -278,7 +278,7 @@ EidosValue_SP Eidos_ExecuteFunction_strcontains(const std::vector } else { - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -321,7 +321,7 @@ EidosValue_SP Eidos_ExecuteFunction_strfind(const std::vector &p_ } else { - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -364,7 +364,7 @@ EidosValue_SP Eidos_ExecuteFunction_strprefix(const std::vector & } else { - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -452,7 +452,7 @@ EidosValue_SP Eidos_ExecuteFunction_strsuffix(const std::vector & } else { - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -529,7 +529,7 @@ EidosValue_SP Eidos_ExecuteFunction_substr(const std::vector &p_a } else { - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue *arg_first = p_arguments[1].get(); int arg_first_count = arg_first->Count(); bool first_singleton = (arg_first_count == 1); diff --git a/eidos/eidos_functions_values.cpp b/eidos/eidos_functions_values.cpp index c24a5daa..8088d534 100644 --- a/eidos/eidos_functions_values.cpp +++ b/eidos/eidos_functions_values.cpp @@ -144,7 +144,7 @@ EidosValue_SP Eidos_ExecuteFunction_integer(const std::vector &p_ } else { - const int64_t *positions_data = fill2Indices_value->IntVector()->data(); + const int64_t *positions_data = fill2Indices_value->IntData(); for (int positions_index = 0; positions_index < positions_count; ++positions_index) { @@ -347,16 +347,16 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a case EidosValueType::kValueVOID: break; // NOLINT(*-branch-clone) : intentional consecutive branches case EidosValueType::kValueNULL: break; case EidosValueType::kValueLogical: - Eidos_ran_shuffle(main_thread_rng, result->LogicalVector_Mutable()->data(), x_count); + Eidos_ran_shuffle(main_thread_rng, result->LogicalData_Mutable(), x_count); break; case EidosValueType::kValueInt: - Eidos_ran_shuffle(main_thread_rng, result->IntVector_Mutable()->data(), x_count); + Eidos_ran_shuffle(main_thread_rng, result->IntData_Mutable(), x_count); break; case EidosValueType::kValueFloat: - Eidos_ran_shuffle(main_thread_rng, result->FloatVector_Mutable()->data(), x_count); + Eidos_ran_shuffle(main_thread_rng, result->FloatData_Mutable(), x_count); break; case EidosValueType::kValueObject: - Eidos_ran_shuffle(main_thread_rng, result->ObjectElementVector_Mutable()->data(), x_count); + Eidos_ran_shuffle(main_thread_rng, result->ObjectData_Mutable(), x_count); break; default: EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_sample): (internal error) unsupported type in sample()" << EidosTerminate(nullptr); @@ -413,7 +413,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a if (weights_type == EidosValueType::kValueFloat) { - weights_float = weights_value->FloatVector()->data(); + weights_float = weights_value->FloatData(); for (int value_index = 0; value_index < x_count; ++value_index) { @@ -427,7 +427,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else // EidosValueType::kValueInt : convert the weights to doubles { - const int64_t *weights_int = weights_value->IntVector()->data(); + const int64_t *weights_int = weights_value->IntData(); weights_float_malloced = (double *)malloc(x_count * sizeof(double)); @@ -461,7 +461,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a // now treat each type separately if (x_type == EidosValueType::kValueInt) { - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(sample_size); int64_t *int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -482,7 +482,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(sample_size); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -503,7 +503,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else if (x_type == EidosValueType::kValueObject) { - EidosObject * const *object_data = x_value->ObjectElementVector()->data(); + EidosObject * const *object_data = x_value->ObjectData(); const EidosClass *object_class = ((EidosValue_Object *)x_value)->Class(); EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(object_class))->resize_no_initialize(sample_size); EidosObject **object_result_data = object_result->data(); @@ -556,7 +556,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a // handle the weights vector with separate cases for float and integer, so we can access it directly for speed else if (weights_type == EidosValueType::kValueFloat) { - const double *weights_float = weights_value->FloatVector()->data(); + const double *weights_float = weights_value->FloatData(); double weights_sum = 0.0; for (int value_index = 0; value_index < x_count; ++value_index) @@ -651,7 +651,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else if (weights_type == EidosValueType::kValueInt) { - const int64_t *weights_int = weights_value->IntVector()->data(); + const int64_t *weights_int = weights_value->IntData(); int64_t weights_sum = 0; for (int value_index = 0; value_index < x_count; ++value_index) @@ -778,7 +778,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else if (x_type == EidosValueType::kValueInt) { - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(sample_size); int64_t *int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -798,7 +798,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(sample_size); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -818,7 +818,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else if (x_type == EidosValueType::kValueObject) { - EidosObject * const *object_data = x_value->ObjectElementVector()->data(); + EidosObject * const *object_data = x_value->ObjectData(); const EidosClass *object_class = ((EidosValue_Object *)x_value)->Class(); EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(object_class))->resize_no_initialize(sample_size); EidosObject **object_result_data = object_result->data(); @@ -1131,7 +1131,7 @@ EidosValue_SP Eidos_ExecuteFunction_all(const std::vector &p_argu EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_all): function all() requires that all arguments be of type logical." << EidosTerminate(nullptr); int arg_count = arg_value->Count(); - const eidos_logical_t *logical_data = arg_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = arg_value->LogicalData(); for (int value_index = 0; value_index < arg_count; ++value_index) if (!logical_data[value_index]) @@ -1163,7 +1163,7 @@ EidosValue_SP Eidos_ExecuteFunction_any(const std::vector &p_argu EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_any): function any() requires that all arguments be of type logical." << EidosTerminate(nullptr); int arg_count = arg_value->Count(); - const eidos_logical_t *logical_data = arg_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = arg_value->LogicalData(); for (int value_index = 0; value_index < arg_count; ++value_index) if (logical_data[value_index]) @@ -1481,7 +1481,7 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a EidosValue *test_value = p_arguments[0].get(); int test_count = test_value->Count(); - const eidos_logical_t *logical_vec = (*test_value->LogicalVector()).data(); + const eidos_logical_t *logical_vec = test_value->LogicalData(); EidosValue *trueValues_value = p_arguments[1].get(); EidosValueType trueValues_type = trueValues_value->Type(); @@ -1502,8 +1502,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a // Use direct access to make this fast if (trueValues_type == EidosValueType::kValueLogical) { - const eidos_logical_t *true_vec = trueValues_value->LogicalVector()->data(); - const eidos_logical_t *false_vec = falseValues_value->LogicalVector()->data(); + const eidos_logical_t *true_vec = trueValues_value->LogicalData(); + const eidos_logical_t *false_vec = falseValues_value->LogicalData(); EidosValue_Logical_SP logical_result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); EidosValue_Logical *logical_result = logical_result_SP->resize_no_initialize(test_count); @@ -1514,8 +1514,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a } else if (trueValues_type == EidosValueType::kValueInt) { - const int64_t *true_data = trueValues_value->IntVector()->data(); - const int64_t *false_data = falseValues_value->IntVector()->data(); + const int64_t *true_data = trueValues_value->IntData(); + const int64_t *false_data = falseValues_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(test_count); @@ -1526,8 +1526,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a } else if (trueValues_type == EidosValueType::kValueFloat) { - const double *true_data = trueValues_value->FloatVector()->data(); - const double *false_data = falseValues_value->FloatVector()->data(); + const double *true_data = trueValues_value->FloatData(); + const double *false_data = falseValues_value->FloatData(); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(test_count); @@ -1538,8 +1538,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a } else if (trueValues_type == EidosValueType::kValueString) { - const std::vector &true_vec = (*trueValues_value->StringVector()); - const std::vector &false_vec = (*falseValues_value->StringVector()); + const std::string *true_vec = trueValues_value->StringData(); + const std::string *false_vec = falseValues_value->StringData(); EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); EidosValue_String_vector *string_result = string_result_SP->Reserve(test_count); @@ -1556,8 +1556,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a if (trueValues_class != falseValues_class) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_ifelse): objects of different types cannot be mixed in function ifelse()." << EidosTerminate(nullptr); - EidosObject * const *true_vec = trueValues_value->ObjectElementVector()->data(); - EidosObject * const *false_vec = falseValues_value->ObjectElementVector()->data(); + EidosObject * const *true_vec = trueValues_value->ObjectData(); + EidosObject * const *false_vec = falseValues_value->ObjectData(); EidosValue_Object_vector_SP object_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(trueValues_class)); EidosValue_Object_vector *object_result = object_result_SP->resize_no_initialize_RR(test_count); @@ -1780,7 +1780,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar if (x_type == EidosValueType::kValueLogical) { eidos_logical_t value0 = x_value->LogicalAtIndex(0, nullptr); - const eidos_logical_t *logical_data1 = table_value->LogicalVector()->data(); + const eidos_logical_t *logical_data1 = table_value->LogicalData(); for (table_index = 0; table_index < table_count; ++table_index) if (value0 == logical_data1[table_index]) @@ -1792,7 +1792,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueInt) { int64_t value0 = x_value->IntAtIndex(0, nullptr); - const int64_t *int_data1 = table_value->IntVector()->data(); + const int64_t *int_data1 = table_value->IntData(); for (table_index = 0; table_index < table_count; ++table_index) if (value0 == int_data1[table_index]) @@ -1804,7 +1804,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueFloat) { double value0 = x_value->FloatAtIndex(0, nullptr); - const double *float_data1 = table_value->FloatVector()->data(); + const double *float_data1 = table_value->FloatData(); for (table_index = 0; table_index < table_count; ++table_index) { @@ -1820,7 +1820,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueString) { const std::string &value0 = ((EidosValue_String *)x_value)->StringRefAtIndex(0, nullptr); - const std::vector &string_vec1 = *table_value->StringVector(); + const std::string *string_vec1 = table_value->StringData(); for (table_index = 0; table_index < table_count; ++table_index) if (value0 == string_vec1[table_index]) @@ -1832,7 +1832,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else // if (x_type == EidosValueType::kValueObject) { EidosObject *value0 = x_value->ObjectElementAtIndex(0, nullptr); - EidosObject * const *objelement_vec1 = table_value->ObjectElementVector()->data(); + EidosObject * const *objelement_vec1 = table_value->ObjectData(); for (table_index = 0; table_index < table_count; ++table_index) if (value0 == objelement_vec1[table_index]) @@ -1853,7 +1853,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar if (x_type == EidosValueType::kValueLogical) { eidos_logical_t value1 = table_value->LogicalAtIndex(0, nullptr); - const eidos_logical_t *logical_data0 = x_value->LogicalVector()->data(); + const eidos_logical_t *logical_data0 = x_value->LogicalData(); for (int value_index = 0; value_index < x_count; ++value_index) int_result->set_int_no_check(logical_data0[value_index] == value1 ? 0 : -1, value_index); @@ -1861,7 +1861,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueInt) { int64_t value1 = table_value->IntAtIndex(0, nullptr); - const int64_t *int_data0 = x_value->IntVector()->data(); + const int64_t *int_data0 = x_value->IntData(); for (int value_index = 0; value_index < x_count; ++value_index) int_result->set_int_no_check(int_data0[value_index] == value1 ? 0 : -1, value_index); @@ -1869,7 +1869,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueFloat) { double value1 = table_value->FloatAtIndex(0, nullptr); - const double *float_data0 = x_value->FloatVector()->data(); + const double *float_data0 = x_value->FloatData(); for (int value_index = 0; value_index < x_count; ++value_index) { @@ -1881,7 +1881,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueString) { const std::string &value1 = ((EidosValue_String *)table_value)->StringRefAtIndex(0, nullptr); - const std::vector &string_vec0 = *x_value->StringVector(); + const std::string *string_vec0 = x_value->StringData(); for (int value_index = 0; value_index < x_count; ++value_index) int_result->set_int_no_check(string_vec0[value_index] == value1 ? 0 : -1, value_index); @@ -1889,7 +1889,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueObject) { EidosObject *value1 = table_value->ObjectElementAtIndex(0, nullptr); - EidosObject * const *objelement_vec0 = x_value->ObjectElementVector()->data(); + EidosObject * const *objelement_vec0 = x_value->ObjectData(); for (int value_index = 0; value_index < x_count; ++value_index) int_result->set_int_no_check(objelement_vec0[value_index] == value1 ? 0 : -1, value_index); @@ -1906,8 +1906,8 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical_data0 = x_value->LogicalVector()->data(); - const eidos_logical_t *logical_data1 = table_value->LogicalVector()->data(); + const eidos_logical_t *logical_data0 = x_value->LogicalData(); + const eidos_logical_t *logical_data1 = table_value->LogicalData(); for (int value_index = 0; value_index < x_count; ++value_index) { @@ -1920,8 +1920,8 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueInt) { - const int64_t *int_data0 = x_value->IntVector()->data(); - const int64_t *int_data1 = table_value->IntVector()->data(); + const int64_t *int_data0 = x_value->IntData(); + const int64_t *int_data1 = table_value->IntData(); if ((x_count >= 500) && (table_count >= 5)) // a guess based on timing data; will be platform-dependent and dataset-dependent { @@ -1966,8 +1966,8 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data0 = x_value->FloatVector()->data(); - const double *float_data1 = table_value->FloatVector()->data(); + const double *float_data0 = x_value->FloatData(); + const double *float_data1 = table_value->FloatData(); if ((x_count >= 500) && (table_count >= 5)) // a guess based on timing data; will be platform-dependent and dataset-dependent { @@ -2018,8 +2018,8 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueString) { - const std::vector &string_vec0 = *x_value->StringVector(); - const std::vector &string_vec1 = *table_value->StringVector(); + const std::string *string_vec0 = x_value->StringData(); + const std::string *string_vec1 = table_value->StringData(); if ((x_count >= 500) && (table_count >= 5)) // a guess based on timing data; will be platform-dependent and dataset-dependent { @@ -2065,8 +2065,8 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueObject) { - EidosObject * const *objelement_vec0 = x_value->ObjectElementVector()->data(); - EidosObject * const *objelement_vec1 = table_value->ObjectElementVector()->data(); + EidosObject * const *objelement_vec0 = x_value->ObjectData(); + EidosObject * const *objelement_vec1 = table_value->ObjectData(); if ((x_count >= 500) && (table_count >= 5)) // a guess based on timing data; will be platform-dependent and dataset-dependent { @@ -2142,13 +2142,13 @@ EidosValue_SP Eidos_ExecuteFunction_order(const std::vector &p_ar std::vector order; if (x_type == EidosValueType::kValueLogical) - order = EidosSortIndexes(x_value->LogicalVector()->data(), x_count, ascending); + order = EidosSortIndexes(x_value->LogicalData(), x_count, ascending); else if (x_type == EidosValueType::kValueInt) - order = EidosSortIndexes(x_value->IntVector()->data(), x_count, ascending); + order = EidosSortIndexes(x_value->IntData(), x_count, ascending); else if (x_type == EidosValueType::kValueFloat) - order = EidosSortIndexes(x_value->FloatVector()->data(), x_count, ascending); + order = EidosSortIndexes(x_value->FloatData(), x_count, ascending); else if (x_type == EidosValueType::kValueString) - order = EidosSortIndexes(*x_value->StringVector(), ascending); + order = EidosSortIndexes(x_value->StringData(), x_count, ascending); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(order)); result_SP = EidosValue_SP(int_result); @@ -2337,7 +2337,7 @@ EidosValue_SP Eidos_ExecuteFunction_rank(const std::vector &p_arg { // construct our vector of pairs: std::pair - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); for (int index = 0; index < x_count; ++index) pairs.emplace_back(int_data[index], index); @@ -2417,7 +2417,7 @@ EidosValue_SP Eidos_ExecuteFunction_rank(const std::vector &p_arg { // construct our vector of pairs: std::pair - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); for (int index = 0; index < x_count; ++index) pairs.emplace_back(float_data[index], index); @@ -2606,7 +2606,7 @@ EidosValue_SP Eidos_ExecuteFunction_tabulate(const std::vector &p // set up to work with either a singleton or a non-singleton vector int64_t singleton_value = (value_count == 1) ? bin_value->IntAtIndex(0, nullptr) : 0; - const int64_t *int_data = (value_count == 1) ? &singleton_value : bin_value->IntVector()->data(); + const int64_t *int_data = (value_count == 1) ? &singleton_value : bin_value->IntData(); // determine maxbin int64_t maxbin; @@ -2709,7 +2709,7 @@ EidosValue_SP Eidos_ExecuteFunction_which(const std::vector &p_ar EidosValue *x_value = p_arguments[0].get(); int x_count = x_value->Count(); - const eidos_logical_t *logical_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = x_value->LogicalData(); EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); result_SP = EidosValue_SP(int_result); @@ -2746,7 +2746,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const eidos_logical_t *logical_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = x_value->LogicalData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2762,7 +2762,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2778,7 +2778,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2794,7 +2794,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_String_vector; we can use the fast API - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2836,7 +2836,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const eidos_logical_t *logical_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = x_value->LogicalData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2852,7 +2852,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2868,7 +2868,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2884,7 +2884,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_String_vector; we can use the fast API - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); for (int value_index = 1; value_index < x_count; ++value_index) { diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index 4ac3f1d5..b09a43e6 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -396,7 +396,7 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, else if (second_child_count) { // fast vector access for the non-singleton case - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_idx = 0; value_idx < second_child_count; value_idx++) { @@ -479,7 +479,7 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, if (subset_count != dim_size) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): the '[]' operator requires that the size() of a logical index operand must match the corresponding dimension of the indexed operand." << EidosTerminate(parent_token); - const eidos_logical_t *logical_index_data = subset_value->LogicalVector()->data(); + const eidos_logical_t *logical_index_data = subset_value->LogicalData(); for (int dim_index = 0; dim_index < dim_size; dim_index++) if (logical_index_data[dim_index]) @@ -1750,7 +1750,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Subset(const EidosASTNode *p_node) if (subset_count != dim_size) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Subset): the '[]' operator requires that the size() of a logical index operand must match the corresponding dimension of the indexed operand." << EidosTerminate(operator_token); - const eidos_logical_t *logical_index_data = subset_value->LogicalVector()->data(); + const eidos_logical_t *logical_index_data = subset_value->LogicalData(); for (int dim_index = 0; dim_index < dim_size; dim_index++) if (logical_index_data[dim_index]) @@ -2019,8 +2019,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) } else { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const int64_t *second_child_data = second_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2046,7 +2046,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) else if (first_child_count == 1) { int64_t singleton_int = first_child_value->IntAtIndex(0, operator_token); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(second_child_count); @@ -2069,7 +2069,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) } else if (second_child_count == 1) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); int64_t singleton_int = second_child_value->IntAtIndex(0, operator_token); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2115,24 +2115,24 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] + second_child_data[value_index], value_index); } else if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueInt)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] + second_child_data[value_index], value_index); } else // ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueFloat)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] + second_child_data[value_index], value_index); @@ -2149,14 +2149,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) if (second_child_type == EidosValueType::kValueInt) { - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(singleton_float + second_child_data[value_index], value_index); } else // (second_child_type == EidosValueType::kValueFloat) { - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(singleton_float + second_child_data[value_index], value_index); @@ -2172,14 +2172,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) if (first_child_type == EidosValueType::kValueInt) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] + singleton_float, value_index); } else // (first_child_type == EidosValueType::kValueFloat) { - const double *first_child_data = first_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] + singleton_float, value_index); @@ -2238,7 +2238,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2268,7 +2268,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else { - const double *first_child_data = first_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); @@ -2322,8 +2322,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const int64_t *second_child_data = second_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2349,7 +2349,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) else if (first_child_count == 1) { int64_t singleton_int = first_child_value->IntAtIndex(0, operator_token); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(second_child_count); @@ -2372,7 +2372,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else if (second_child_count == 1) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); int64_t singleton_int = second_child_value->IntAtIndex(0, operator_token); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2415,24 +2415,24 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] - second_child_data[value_index], value_index); } else if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueInt)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] - second_child_data[value_index], value_index); } else // ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueFloat)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] - second_child_data[value_index], value_index); @@ -2449,14 +2449,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) if (second_child_type == EidosValueType::kValueInt) { - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(singleton_float - second_child_data[value_index], value_index); } else // (second_child_type == EidosValueType::kValueFloat) { - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(singleton_float - second_child_data[value_index], value_index); @@ -2472,14 +2472,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) if (first_child_type == EidosValueType::kValueInt) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] - singleton_float, value_index); } else // (first_child_type == EidosValueType::kValueFloat) { - const double *first_child_data = first_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] - singleton_float, value_index); @@ -2549,32 +2549,32 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(fmod(first_child_data[value_index], second_child_data[value_index]), value_index); } else if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueInt)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(fmod(first_child_data[value_index], second_child_data[value_index]), value_index); } else if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueFloat)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(fmod(first_child_data[value_index], second_child_data[value_index]), value_index); } else // ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(fmod(first_child_data[value_index], second_child_data[value_index]), value_index); @@ -2591,14 +2591,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) if (second_child_type == EidosValueType::kValueInt) { - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(fmod(singleton_float, second_child_data[value_index]), value_index); } else // (second_child_type == EidosValueType::kValueFloat) { - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(fmod(singleton_float, second_child_data[value_index]), value_index); @@ -2614,14 +2614,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) if (first_child_type == EidosValueType::kValueInt) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(fmod(first_child_data[value_index], singleton_float), value_index); } else // (first_child_type == EidosValueType::kValueFloat) { - const double *first_child_data = first_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(fmod(first_child_data[value_index], singleton_float), value_index); @@ -2694,8 +2694,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) } else { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const int64_t *second_child_data = second_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2731,24 +2731,24 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] * second_child_data[value_index], value_index); } else if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueInt)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] * second_child_data[value_index], value_index); } else // ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueFloat)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] * second_child_data[value_index], value_index); @@ -2783,7 +2783,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) // OK, we've got good operands; calculate the result. If both operands are int, the result is int, otherwise float. if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { - const int64_t *any_count_data = any_count_child->IntVector()->data(); + const int64_t *any_count_data = any_count_child->IntData(); int64_t singleton_int = one_count_child->IntAtIndex(0, operator_token); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(any_count); @@ -2807,7 +2807,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) } else if (any_type == EidosValueType::kValueInt) { - const int64_t *any_count_data = any_count_child->IntVector()->data(); + const int64_t *any_count_data = any_count_child->IntData(); double singleton_float = one_count_child->FloatAtIndex(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(any_count); @@ -2819,7 +2819,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) } else // (any_type == EidosValueType::kValueFloat) { - const double *any_count_data = any_count_child->FloatVector()->data(); + const double *any_count_data = any_count_child->FloatData(); double singleton_float = one_count_child->FloatAtIndex(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(any_count); @@ -2894,32 +2894,32 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] / second_child_data[value_index], value_index); } else if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueInt)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] / second_child_data[value_index], value_index); } else if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueFloat)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] / second_child_data[value_index], value_index); } else // ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] / (double)second_child_data[value_index], value_index); @@ -2936,14 +2936,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) if (second_child_type == EidosValueType::kValueInt) { - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(singleton_float / second_child_data[value_index], value_index); } else // (second_child_type == EidosValueType::kValueFloat) { - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(singleton_float / second_child_data[value_index], value_index); @@ -2959,14 +2959,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) if (first_child_type == EidosValueType::kValueInt) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] / singleton_float, value_index); } else // (first_child_type == EidosValueType::kValueFloat) { - const double *first_child_data = first_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] / singleton_float, value_index); @@ -3071,32 +3071,32 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(pow(first_child_data[value_index], second_child_data[value_index]), value_index); } else if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueInt)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(pow(first_child_data[value_index], second_child_data[value_index]), value_index); } else if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueFloat)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(pow(first_child_data[value_index], second_child_data[value_index]), value_index); } else // ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(pow(first_child_data[value_index], second_child_data[value_index]), value_index); @@ -3113,14 +3113,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) if (second_child_type == EidosValueType::kValueInt) { - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(pow(singleton_float, second_child_data[value_index]), value_index); } else // (second_child_type == EidosValueType::kValueFloat) { - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(pow(singleton_float, second_child_data[value_index]), value_index); @@ -3136,14 +3136,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) if (first_child_type == EidosValueType::kValueInt) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(pow(first_child_data[value_index], singleton_float), value_index); } else // (first_child_type == EidosValueType::kValueFloat) { - const double *first_child_data = first_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(pow(first_child_data[value_index], singleton_float), value_index); @@ -3648,21 +3648,21 @@ EidosValue_SP EidosInterpreter::Evaluate_Not(const EidosASTNode *p_node) if (first_child_type == EidosValueType::kValueLogical) { - const eidos_logical_t *child_data = first_child_value->LogicalVector()->data(); + const eidos_logical_t *child_data = first_child_value->LogicalData(); for (int value_index = 0; value_index < first_child_count; ++value_index) result->set_logical_no_check(!child_data[value_index], value_index); } else if (first_child_type == EidosValueType::kValueInt) { - const int64_t *child_data = first_child_value->IntVector()->data(); + const int64_t *child_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) result->set_logical_no_check(child_data[value_index] == 0, value_index); } else if (first_child_type == EidosValueType::kValueString) { - const std::vector &child_vec = (*first_child_value->StringVector()); + const std::string *child_vec = first_child_value->StringData(); for (int value_index = 0; value_index < first_child_count; ++value_index) result->set_logical_no_check(child_vec[value_index].length() == 0, value_index); @@ -3735,7 +3735,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) { case EidosTokenType::kTokenPlus: { - int64_t &operand1_value = int_singleton->IntValue_Mutable(); + int64_t &operand1_value = int_singleton->IntData_Mutable()[0]; bool overflow = Eidos_add_overflow(operand1_value, operand2_value, &operand1_value); if (overflow) @@ -3744,7 +3744,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) } case EidosTokenType::kTokenMinus: { - int64_t &operand1_value = int_singleton->IntValue_Mutable(); + int64_t &operand1_value = int_singleton->IntData_Mutable()[0]; bool overflow = Eidos_sub_overflow(operand1_value, operand2_value, &operand1_value); if (overflow) @@ -3753,7 +3753,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) } case EidosTokenType::kTokenMult: { - int64_t &operand1_value = int_singleton->IntValue_Mutable(); + int64_t &operand1_value = int_singleton->IntData_Mutable()[0]; bool overflow = Eidos_mul_overflow(operand1_value, operand2_value, &operand1_value); if (overflow) @@ -3766,7 +3766,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) } else { - int64_t *int_data = lvalue->IntVector_Mutable()->data(); + int64_t *int_data = lvalue->IntData_Mutable(); switch (compound_operator) { @@ -3827,24 +3827,24 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) switch (compound_operator) { case EidosTokenType::kTokenPlus: - float_singleton->FloatValue_Mutable() += operand2_value; + float_singleton->FloatData_Mutable()[0] += operand2_value; goto compoundAssignmentSuccess; case EidosTokenType::kTokenMinus: - float_singleton->FloatValue_Mutable() -= operand2_value; + float_singleton->FloatData_Mutable()[0] -= operand2_value; goto compoundAssignmentSuccess; case EidosTokenType::kTokenMult: - float_singleton->FloatValue_Mutable() *= operand2_value; + float_singleton->FloatData_Mutable()[0] *= operand2_value; goto compoundAssignmentSuccess; case EidosTokenType::kTokenDiv: - float_singleton->FloatValue_Mutable() /= operand2_value; + float_singleton->FloatData_Mutable()[0] /= operand2_value; goto compoundAssignmentSuccess; case EidosTokenType::kTokenMod: { - double &operand1_value = float_singleton->FloatValue_Mutable(); + double &operand1_value = float_singleton->FloatData_Mutable()[0]; operand1_value = fmod(operand1_value, operand2_value); goto compoundAssignmentSuccess; @@ -3852,7 +3852,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) case EidosTokenType::kTokenExp: { - double &operand1_value = float_singleton->FloatValue_Mutable(); + double &operand1_value = float_singleton->FloatData_Mutable()[0]; operand1_value = pow(operand1_value, operand2_value); goto compoundAssignmentSuccess; @@ -3866,7 +3866,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) } else { - double *float_data = lvalue->FloatVector_Mutable()->data(); + double *float_data = lvalue->FloatData_Mutable(); switch (compound_operator) { @@ -4054,8 +4054,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { // Direct float-to-float compare can be optimized through vector access - const double *float1_data = first_child_value->FloatVector()->data(); - const double *float2_data = second_child_value->FloatVector()->data(); + const double *float1_data = first_child_value->FloatData(); + const double *float2_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(float1_data[value_index] == float2_data[value_index], value_index); @@ -4063,8 +4063,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) else if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { // Direct int-to-int compare can be optimized through vector access - const int64_t *int1_data = first_child_value->IntVector()->data(); - const int64_t *int2_data = second_child_value->IntVector()->data(); + const int64_t *int1_data = first_child_value->IntData(); + const int64_t *int2_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(int1_data[value_index] == int2_data[value_index], value_index); @@ -4072,8 +4072,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) else if ((first_child_type == EidosValueType::kValueObject) && (second_child_type == EidosValueType::kValueObject)) { // Direct object-to-object compare can be optimized through vector access - EidosObject * const *obj1_vec = first_child_value->ObjectElementVector()->data(); - EidosObject * const *obj2_vec = second_child_value->ObjectElementVector()->data(); + EidosObject * const *obj1_vec = first_child_value->ObjectData(); + EidosObject * const *obj2_vec = second_child_value->ObjectData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(obj1_vec[value_index] == obj2_vec[value_index], value_index); @@ -4111,7 +4111,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) { // Direct float-to-float compare can be optimized through vector access; note the singleton might get promoted to float double float1 = first_child_value->FloatAtIndex(0, operator_token); - const double *float_data = second_child_value->FloatVector()->data(); + const double *float_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) logical_result->set_logical_no_check(float1 == float_data[value_index], value_index); @@ -4120,7 +4120,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) { // Direct int-to-int compare can be optimized through vector access; note the singleton might get promoted to int int64_t int1 = first_child_value->IntAtIndex(0, operator_token); - const int64_t *int_data = second_child_value->IntVector()->data(); + const int64_t *int_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) logical_result->set_logical_no_check(int1 == int_data[value_index], value_index); @@ -4129,7 +4129,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) { // Direct object-to-object compare can be optimized through vector access EidosObject *obj1 = first_child_value->ObjectElementAtIndex(0, operator_token); - EidosObject * const *obj_vec = second_child_value->ObjectElementVector()->data(); + EidosObject * const *obj_vec = second_child_value->ObjectData(); for (int value_index = 0; value_index < second_child_count; ++value_index) logical_result->set_logical_no_check(obj1 == obj_vec[value_index], value_index); @@ -4166,7 +4166,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) { // Direct float-to-float compare can be optimized through vector access; note the singleton might get promoted to float double float2 = second_child_value->FloatAtIndex(0, operator_token); - const double *float_data = first_child_value->FloatVector()->data(); + const double *float_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(float_data[value_index] == float2, value_index); @@ -4175,7 +4175,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) { // Direct int-to-int compare can be optimized through vector access; note the singleton might get promoted to int int64_t int2 = second_child_value->IntAtIndex(0, operator_token); - const int64_t *int_data = first_child_value->IntVector()->data(); + const int64_t *int_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(int_data[value_index] == int2, value_index); @@ -4184,7 +4184,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) { // Direct object-to-object compare can be optimized through vector access EidosObject *obj2 = second_child_value->ObjectElementAtIndex(0, operator_token); - EidosObject * const *obj_vec = first_child_value->ObjectElementVector()->data(); + EidosObject * const *obj_vec = first_child_value->ObjectData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(obj_vec[value_index] == obj2, value_index); @@ -4880,8 +4880,8 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { // Direct float-to-float compare can be optimized through vector access - const double *float1_data = first_child_value->FloatVector()->data(); - const double *float2_data = second_child_value->FloatVector()->data(); + const double *float1_data = first_child_value->FloatData(); + const double *float2_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(float1_data[value_index] != float2_data[value_index], value_index); @@ -4889,8 +4889,8 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) else if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { // Direct int-to-int compare can be optimized through vector access - const int64_t *int1_data = first_child_value->IntVector()->data(); - const int64_t *int2_data = second_child_value->IntVector()->data(); + const int64_t *int1_data = first_child_value->IntData(); + const int64_t *int2_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(int1_data[value_index] != int2_data[value_index], value_index); @@ -4898,8 +4898,8 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) else if ((first_child_type == EidosValueType::kValueObject) && (second_child_type == EidosValueType::kValueObject)) { // Direct object-to-object compare can be optimized through vector access - EidosObject * const *obj1_vec = first_child_value->ObjectElementVector()->data(); - EidosObject * const *obj2_vec = second_child_value->ObjectElementVector()->data(); + EidosObject * const *obj1_vec = first_child_value->ObjectData(); + EidosObject * const *obj2_vec = second_child_value->ObjectData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(obj1_vec[value_index] != obj2_vec[value_index], value_index); @@ -4937,7 +4937,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) { // Direct float-to-float compare can be optimized through vector access; note the singleton might get promoted to float double float1 = first_child_value->FloatAtIndex(0, operator_token); - const double *float_data = second_child_value->FloatVector()->data(); + const double *float_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) logical_result->set_logical_no_check(float1 != float_data[value_index], value_index); @@ -4946,7 +4946,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) { // Direct int-to-int compare can be optimized through vector access; note the singleton might get promoted to int int64_t int1 = first_child_value->IntAtIndex(0, operator_token); - const int64_t *int_data = second_child_value->IntVector()->data(); + const int64_t *int_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) logical_result->set_logical_no_check(int1 != int_data[value_index], value_index); @@ -4955,7 +4955,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) { // Direct object-to-object compare can be optimized through vector access EidosObject *obj1 = first_child_value->ObjectElementAtIndex(0, operator_token); - EidosObject * const *obj_vec = second_child_value->ObjectElementVector()->data(); + EidosObject * const *obj_vec = second_child_value->ObjectData(); for (int value_index = 0; value_index < second_child_count; ++value_index) logical_result->set_logical_no_check(obj1 != obj_vec[value_index], value_index); @@ -4992,7 +4992,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) { // Direct float-to-float compare can be optimized through vector access; note the singleton might get promoted to float double float2 = second_child_value->FloatAtIndex(0, operator_token); - const double *float_data = first_child_value->FloatVector()->data(); + const double *float_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(float_data[value_index] != float2, value_index); @@ -5001,7 +5001,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) { // Direct int-to-int compare can be optimized through vector access; note the singleton might get promoted to int int64_t int2 = second_child_value->IntAtIndex(0, operator_token); - const int64_t *int_data = first_child_value->IntVector()->data(); + const int64_t *int_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(int_data[value_index] != int2, value_index); @@ -5010,7 +5010,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) { // Direct object-to-object compare can be optimized through vector access EidosObject *obj2 = second_child_value->ObjectElementAtIndex(0, operator_token); - EidosObject * const *obj_vec = first_child_value->ObjectElementVector()->data(); + EidosObject * const *obj_vec = first_child_value->ObjectData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(obj_vec[value_index] != obj2, value_index); @@ -5809,7 +5809,7 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) // EidosValue that we stick new values into – much, much faster. if (range_type == EidosValueType::kValueInt) { - const int64_t *range_data = range_value->IntVector()->data(); + const int64_t *range_data = range_value->IntData(); EidosValue_Int_singleton_SP index_value_SP = EidosValue_Int_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(0)); EidosValue_Int_singleton *index_value = index_value_SP.get(); @@ -5842,7 +5842,7 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) } else if (range_type == EidosValueType::kValueFloat) { - const double *range_data = range_value->FloatVector()->data(); + const double *range_data = range_value->FloatData(); EidosValue_Float_singleton_SP index_value_SP = EidosValue_Float_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(0)); EidosValue_Float_singleton *index_value = index_value_SP.get(); @@ -5875,7 +5875,7 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) } else if (range_type == EidosValueType::kValueString) { - const std::vector &range_vec = *range_value->StringVector(); + const std::string *range_vec = range_value->StringData(); EidosValue_String_singleton_SP index_value_SP = EidosValue_String_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_empty_string)); EidosValue_String_singleton *index_value = index_value_SP.get(); @@ -5908,7 +5908,7 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) } else if (range_type == EidosValueType::kValueObject) { - EidosObject * const *range_vec = range_value->ObjectElementVector()->data(); + EidosObject * const *range_vec = range_value->ObjectData(); EidosValue_Object_singleton_SP index_value_SP = EidosValue_Object_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(nullptr, ((EidosValue_Object *)range_value.get())->Class())); EidosValue_Object_singleton *index_value = index_value_SP.get(); @@ -5941,7 +5941,7 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) } else if (range_type == EidosValueType::kValueLogical) { - const eidos_logical_t *range_data = range_value->LogicalVector()->data(); + const eidos_logical_t *range_data = range_value->LogicalData(); EidosValue_Logical_SP index_value_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); EidosValue_Logical *index_value = index_value_SP->resize_no_initialize(1); diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index bf659f6f..fd33e90f 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -871,11 +871,6 @@ const std::string &EidosValue_VOID::ElementType(void) const return gEidosStr_void; } -int EidosValue_VOID::Count_Virtual(void) const -{ - return 0; -} - void EidosValue_VOID::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const { #pragma unused(p_idx) @@ -952,11 +947,6 @@ const std::string &EidosValue_NULL::ElementType(void) const return gEidosStr_NULL; } -int EidosValue_NULL::Count_Virtual(void) const -{ - return 0; -} - void EidosValue_NULL::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const { #pragma unused(p_idx) @@ -1052,11 +1042,6 @@ const std::string &EidosValue_Logical::ElementType(void) const return gEidosStr_logical; } -int EidosValue_Logical::Count_Virtual(void) const -{ - return (int)count_; -} - void EidosValue_Logical::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const { eidos_logical_t value = values_[p_idx]; @@ -1077,7 +1062,7 @@ nlohmann::json EidosValue_Logical::JSONRepresentation(void) const eidos_logical_t EidosValue_Logical::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; @@ -1085,7 +1070,7 @@ eidos_logical_t EidosValue_Logical::LogicalAtIndex(int p_idx, const EidosToken * std::string EidosValue_Logical::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] ? gEidosStr_T : gEidosStr_F); @@ -1093,7 +1078,7 @@ std::string EidosValue_Logical::StringAtIndex(int p_idx, const EidosToken *p_bla int64_t EidosValue_Logical::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] ? 1 : 0); @@ -1101,7 +1086,7 @@ int64_t EidosValue_Logical::IntAtIndex(int p_idx, const EidosToken *p_blame_toke double EidosValue_Logical::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] ? 1.0 : 0.0); @@ -1109,7 +1094,7 @@ double EidosValue_Logical::FloatAtIndex(int p_idx, const EidosToken *p_blame_tok EidosValue_SP EidosValue_Logical::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); @@ -1117,7 +1102,7 @@ EidosValue_SP EidosValue_Logical::GetValueAtIndex(const int p_idx, const EidosTo void EidosValue_Logical::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); values_[p_idx] = p_value.LogicalAtIndex(0, p_blame_token); @@ -1316,11 +1301,6 @@ EidosValue_String_vector::EidosValue_String_vector(std::initializer_list= (int)values_.size())) @@ -1408,11 +1388,6 @@ void EidosValue_String_vector::Sort(bool p_ascending) // EidosValue_String_singleton #pragma mark EidosValue_String_singleton -int EidosValue_String_singleton::Count_Virtual(void) const -{ - return 1; -} - eidos_logical_t EidosValue_String_singleton::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) @@ -1591,14 +1566,9 @@ EidosValue_Int_vector::EidosValue_Int_vector(const int64_t *p_values, size_t p_c set_int_no_check(p_values[index], index); } -int EidosValue_Int_vector::Count_Virtual(void) const -{ - return (int)count_; -} - eidos_logical_t EidosValue_Int_vector::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] == 0 ? false : true); @@ -1606,7 +1576,7 @@ eidos_logical_t EidosValue_Int_vector::LogicalAtIndex(int p_idx, const EidosToke std::string EidosValue_Int_vector::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return std::to_string(values_[p_idx]); // way faster than std::ostringstream @@ -1614,7 +1584,7 @@ std::string EidosValue_Int_vector::StringAtIndex(int p_idx, const EidosToken *p_ int64_t EidosValue_Int_vector::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; @@ -1622,7 +1592,7 @@ int64_t EidosValue_Int_vector::IntAtIndex(int p_idx, const EidosToken *p_blame_t double EidosValue_Int_vector::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; @@ -1630,7 +1600,7 @@ double EidosValue_Int_vector::FloatAtIndex(int p_idx, const EidosToken *p_blame_ EidosValue_SP EidosValue_Int_vector::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(values_[p_idx])); @@ -1638,7 +1608,7 @@ EidosValue_SP EidosValue_Int_vector::GetValueAtIndex(const int p_idx, const Eido void EidosValue_Int_vector::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); values_[p_idx] = p_value.IntAtIndex(0, p_blame_token); @@ -1718,11 +1688,6 @@ void EidosValue_Int_vector::erase_index(size_t p_index) // EidosValue_Int_singleton #pragma mark EidosValue_Int_singleton -int EidosValue_Int_singleton::Count_Virtual(void) const -{ - return 1; -} - eidos_logical_t EidosValue_Int_singleton::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) @@ -1862,14 +1827,9 @@ EidosValue_Float_vector::EidosValue_Float_vector(const double *p_values, size_t set_float_no_check(p_values[index], index); } -int EidosValue_Float_vector::Count_Virtual(void) const -{ - return (int)count_; -} - eidos_logical_t EidosValue_Float_vector::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); double value = values_[p_idx]; @@ -1882,7 +1842,7 @@ eidos_logical_t EidosValue_Float_vector::LogicalAtIndex(int p_idx, const EidosTo std::string EidosValue_Float_vector::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosStringForFloat(values_[p_idx]); @@ -1890,7 +1850,7 @@ std::string EidosValue_Float_vector::StringAtIndex(int p_idx, const EidosToken * int64_t EidosValue_Float_vector::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); double value = values_[p_idx]; @@ -1909,7 +1869,7 @@ int64_t EidosValue_Float_vector::IntAtIndex(int p_idx, const EidosToken *p_blame double EidosValue_Float_vector::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; @@ -1917,7 +1877,7 @@ double EidosValue_Float_vector::FloatAtIndex(int p_idx, const EidosToken *p_blam EidosValue_SP EidosValue_Float_vector::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(values_[p_idx])); @@ -1925,7 +1885,7 @@ EidosValue_SP EidosValue_Float_vector::GetValueAtIndex(const int p_idx, const Ei void EidosValue_Float_vector::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); values_[p_idx] = p_value.FloatAtIndex(0, p_blame_token); @@ -2008,11 +1968,6 @@ void EidosValue_Float_vector::erase_index(size_t p_index) // EidosValue_Float_singleton #pragma mark EidosValue_Float_singleton -int EidosValue_Float_singleton::Count_Virtual(void) const -{ - return 1; -} - eidos_logical_t EidosValue_Float_singleton::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) @@ -2161,9 +2116,7 @@ EidosValue_Object::~EidosValue_Object(void) // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments void EidosValue_Object_vector::PatchPointersByAdding(std::uintptr_t p_pointer_difference) { - size_t value_count = size(); - - for (size_t i = 0; i < value_count; ++i) + for (size_t i = 0; i < count_; ++i) { std::uintptr_t old_element_ptr = reinterpret_cast(values_[i]); std::uintptr_t new_element_ptr = old_element_ptr + p_pointer_difference; @@ -2175,9 +2128,7 @@ void EidosValue_Object_vector::PatchPointersByAdding(std::uintptr_t p_pointer_di // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments void EidosValue_Object_vector::PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) { - size_t value_count = size(); - - for (size_t i = 0; i < value_count; ++i) + for (size_t i = 0; i < count_; ++i) { std::uintptr_t old_element_ptr = reinterpret_cast(values_[i]); std::uintptr_t new_element_ptr = old_element_ptr - p_pointer_difference; @@ -2249,7 +2200,7 @@ nlohmann::json EidosValue_Object::JSONRepresentation(void) const EidosValue_Object_vector::EidosValue_Object_vector(const EidosValue_Object_vector &p_original) : EidosValue_Object(false, p_original.Class()) { - size_t count = p_original.size(); + size_t count = p_original.Count(); EidosObject * const *values = p_original.data(); resize_no_initialize_RR(count); @@ -2333,14 +2284,9 @@ EidosValue_Object_vector::~EidosValue_Object_vector(void) free(values_); } -int EidosValue_Object_vector::Count_Virtual(void) const -{ - return (int)size(); -} - EidosObject *EidosValue_Object_vector::ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ObjectElementAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; @@ -2348,7 +2294,7 @@ EidosObject *EidosValue_Object_vector::ObjectElementAtIndex(int p_idx, const Eid EidosValue_SP EidosValue_Object_vector::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(values_[p_idx], Class())); @@ -2356,7 +2302,7 @@ EidosValue_SP EidosValue_Object_vector::GetValueAtIndex(const int p_idx, const E void EidosValue_Object_vector::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); EidosObject *new_value = p_value.ObjectElementAtIndex(0, p_blame_token); @@ -2404,7 +2350,7 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce // blame token; all errors will be attributed to that function automatically. // length 0 is already sorted - if (size() == 0) + if (count_ == 0) return; // figure out what type the property returns @@ -2557,7 +2503,7 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce EidosValue_SP EidosValue_Object_vector::GetPropertyOfElements(EidosGlobalStringID p_property_id) const { - size_t values_size = (size_t)size(); + size_t values_size = count_; const EidosPropertySignature *signature = class_->SignatureForProperty(p_property_id); if (!signature) @@ -2692,7 +2638,7 @@ void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_prope // We have to check the count ourselves; the signature does not do that for us size_t p_value_count = p_value.Count(); - size_t values_size = (size_t)size(); + size_t values_size = count_; if (p_value_count == 1) { @@ -2742,7 +2688,7 @@ void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_prope EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_method_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) { // This is an instance method, so it gets dispatched to all of our elements - auto values_size = size(); + auto values_size = count_; if (values_size == 0) { @@ -2807,6 +2753,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ // timed all of this, and it really does make a difference; calling a method on a large object vector is very // common, and these optimizations make a substantial difference. In fact, I'm tempted to go even further, // down the road I went down with accelerated properties, but I will hold off on that for now. :-> + // BCH 12/20/2023: the XData() methods now allow us to avoid IsSingleton() and treat the cases jointly. EidosValueMask sig_mask = (p_method_signature->return_mask_ & kEidosValueMaskFlagStrip); bool return_is_singleton = (p_method_signature->return_mask_ & kEidosValueMaskSingleton); @@ -2886,7 +2833,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ { // No singleton special-case for logical; EidosValue_Logical is always a vector int return_count = temp_result->Count(); - const eidos_logical_t *return_data = temp_result->LogicalVector()->data(); + const eidos_logical_t *return_data = temp_result->LogicalData(); for (int return_index = 0; return_index < return_count; return_index++) logical_result->push_logical(return_data[return_index]); @@ -2912,12 +2859,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ p_method_signature->CheckReturn(*temp_result); #endif if (temp_result->Type() == EidosValueType::kValueInt) - { - if (temp_result->IsSingleton()) - integer_result->push_int_no_check(((EidosValue_Int_singleton *)temp_result.get())->IntValue()); - else - integer_result->push_int_no_check(temp_result->IntAtIndex(0, nullptr)); // should not generally get hit since the method should return a singleton - } + integer_result->push_int_no_check(temp_result->IntData()[0]); // else it is a NULL, discard it } } @@ -2932,18 +2874,10 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ if (temp_result->Type() == EidosValueType::kValueInt) { int return_count = temp_result->Count(); + const int64_t *return_data = temp_result->IntData(); - if ((return_count == 1) && temp_result->IsSingleton()) - { - integer_result->push_int(((EidosValue_Int_singleton *)temp_result.get())->IntValue()); - } - else - { - const int64_t *return_data = temp_result->IntVector()->data(); - - for (int return_index = 0; return_index < return_count; return_index++) - integer_result->push_int(return_data[return_index]); - } + for (int return_index = 0; return_index < return_count; return_index++) + integer_result->push_int(return_data[return_index]); } // else it is a NULL, discard it } @@ -2966,12 +2900,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ p_method_signature->CheckReturn(*temp_result); #endif if (temp_result->Type() == EidosValueType::kValueFloat) - { - if (temp_result->IsSingleton()) - float_result->push_float_no_check(((EidosValue_Float_singleton *)temp_result.get())->FloatValue()); - else - float_result->push_float_no_check(temp_result->FloatAtIndex(0, nullptr)); // should not generally get hit since the method should return a singleton - } + float_result->push_float_no_check(temp_result->FloatData()[0]); // else it is a NULL, discard it } } @@ -2986,18 +2915,10 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ if (temp_result->Type() == EidosValueType::kValueFloat) { int return_count = temp_result->Count(); + const double *return_data = temp_result->FloatData(); - if ((return_count == 1) && temp_result->IsSingleton()) - { - float_result->push_float(((EidosValue_Float_singleton *)temp_result.get())->FloatValue()); - } - else - { - const double *return_data = temp_result->FloatVector()->data(); - - for (int return_index = 0; return_index < return_count; return_index++) - float_result->push_float(return_data[return_index]); - } + for (int return_index = 0; return_index < return_count; return_index++) + float_result->push_float(return_data[return_index]); } // else it is a NULL, discard it } @@ -3024,12 +2945,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ p_method_signature->CheckReturn(*temp_result); #endif if (temp_result->Type() == EidosValueType::kValueObject) - { - if (temp_result->IsSingleton()) - object_result->push_object_element_no_check_CRR(((EidosValue_Object_singleton *)temp_result.get())->ObjectElementValue()); - else - object_result->push_object_element_no_check_CRR(temp_result->ObjectElementAtIndex(0, nullptr)); // should not generally get hit since the method should return a singleton - } + object_result->push_object_element_no_check_CRR(temp_result->ObjectData()[0]); // else it is a NULL, discard it } } @@ -3044,18 +2960,10 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ if (temp_result->Type() == EidosValueType::kValueObject) { int return_count = temp_result->Count(); + EidosObject * const *return_data = temp_result->ObjectData(); - if ((return_count == 1) && temp_result->IsSingleton()) - { - object_result->push_object_element_CRR(((EidosValue_Object_singleton *)temp_result.get())->ObjectElementValue()); - } - else - { - EidosObject * const *return_data = temp_result->ObjectElementVector()->data(); - - for (int return_index = 0; return_index < return_count; return_index++) - object_result->push_object_element_CRR(return_data[return_index]); - } + for (int return_index = 0; return_index < return_count; return_index++) + object_result->push_object_element_CRR(return_data[return_index]); } // else it is a NULL, discard it } @@ -3230,11 +3138,6 @@ EidosValue_Object_singleton::~EidosValue_Object_singleton(void) static_cast(value_)->Release(); // unsafe cast to avoid virtual function overhead } -int EidosValue_Object_singleton::Count_Virtual(void) const -{ - return 1; -} - EidosObject *EidosValue_Object_singleton::ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index 61d4ca3c..e89d24c0 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -156,6 +156,7 @@ class EidosValue protected: mutable uint32_t intrusive_ref_count_; // used by Eidos_intrusive_ptr + const EidosValueType cached_type_; // allows Type() to be an inline function; cached at construction uint8_t invisible_; // as in R; if true, the value will not normally be printed to the console uint8_t is_singleton_; // allows Count() and IsSingleton() to be inline; cached at construction @@ -177,6 +178,13 @@ class EidosValue EidosValue(EidosValueType p_value_type, bool p_singleton); // must construct with a type identifier and singleton flag, which will be cached virtual ~EidosValue(void); + // methods that raise due to various causes, used to avoid duplication and allow efficient inlining + void RaiseForUnimplementedVectorCall(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); + void RaiseForUnsupportedConversionCall(const EidosToken *p_blame_token) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); + void RaiseForCapacityViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); + void RaiseForRangeViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); + void RaiseForRetainReleaseViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); + // basic methods inline __attribute__((always_inline)) EidosValueType Type(void) const { return cached_type_; } // the type of the vector, cached at construction inline __attribute__((always_inline)) bool IsSingleton(void) const { return is_singleton_; } // true is the subclass is a singleton subclass (not just if Count()==1) @@ -210,29 +218,23 @@ class EidosValue virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) = 0; // copy a value virtual void Sort(bool p_ascending) = 0; - // Methods to get a type-specific vector for fast manipulation; these raise if called on a value that does not support them. - // This is much faster than using dynamic_cast to achieve the same effect, and much safer than using static_cast + non-virtual function. - // Note that these methods are conventionally used in Eidos by immediately dereferencing to create a reference to the vector; this - // should be safe, since these methods should always raise rather than returning nullptr. - void RaiseForUnimplementedVectorCall(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); - void RaiseForUnsupportedConversionCall(const EidosToken *p_blame_token) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); - void RaiseForCapacityViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); - void RaiseForRangeViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); - void RaiseForRetainReleaseViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); - - virtual const EidosValue_Logical *LogicalVector(void) const { RaiseForUnimplementedVectorCall(); } - virtual EidosValue_Logical *LogicalVector_Mutable(void) { RaiseForUnimplementedVectorCall(); } - virtual const std::vector *StringVector(void) const { RaiseForUnimplementedVectorCall(); } - virtual std::vector *StringVector_Mutable(void) { RaiseForUnimplementedVectorCall(); } - virtual const EidosValue_Int_vector *IntVector(void) const { RaiseForUnimplementedVectorCall(); } - virtual EidosValue_Int_vector *IntVector_Mutable(void) { RaiseForUnimplementedVectorCall(); } - virtual const EidosValue_Float_vector *FloatVector(void) const { RaiseForUnimplementedVectorCall(); } - virtual EidosValue_Float_vector *FloatVector_Mutable(void) { RaiseForUnimplementedVectorCall(); } - virtual const EidosValue_Object_vector *ObjectElementVector(void) const { RaiseForUnimplementedVectorCall(); } - virtual EidosValue_Object_vector *ObjectElementVector_Mutable(void) { RaiseForUnimplementedVectorCall(); } + // Methods to get a type-specific pointer directly to the data of the EidosValue. This is generally good for either + // accessing the values without changing them, or changing them but not changing the length of the vector. You must + // explicitly request mutability. If you want to change the length of the vector, you will want to actually get the + // type-specific vector subclass using dynamic_cast, but it is rare not to already have that pointer in such cases. + virtual const eidos_logical_t *LogicalData(void) const { RaiseForUnimplementedVectorCall(); } + virtual eidos_logical_t *LogicalData_Mutable(void) { RaiseForUnimplementedVectorCall(); } + virtual const std::string *StringData(void) const { RaiseForUnimplementedVectorCall(); } + virtual std::string *StringData_Mutable(void) { RaiseForUnimplementedVectorCall(); } + virtual const int64_t *IntData(void) const { RaiseForUnimplementedVectorCall(); } + virtual int64_t *IntData_Mutable(void) { RaiseForUnimplementedVectorCall(); } + virtual const double *FloatData(void) const { RaiseForUnimplementedVectorCall(); } + virtual double *FloatData_Mutable(void) { RaiseForUnimplementedVectorCall(); } + virtual EidosObject * const *ObjectData(void) const { RaiseForUnimplementedVectorCall(); } + virtual EidosObject **ObjectData_Mutable(void) { RaiseForUnimplementedVectorCall(); } // Dimension support, for matrices and arrays - inline __attribute__((always_inline)) bool IsArray(void) const { return !!dim_; } // true if we have a dimensions buffer – any array, including a matrix + inline __attribute__((always_inline)) bool IsMatrixOrArray(void) const { return !!dim_; } // true if we have a dimensions buffer inline __attribute__((always_inline)) int DimensionCount(void) const { return (!dim_) ? 1 : (int)*dim_; } // 1 for vectors, 2 for matrices, 2...n for arrays (1 not allowed for arrays) inline __attribute__((always_inline)) const int64_t *Dimensions(void) const { return (!dim_) ? nullptr : dim_ + 1; } // nullptr or a pointer into the dim_ buffer @@ -331,13 +333,13 @@ inline __attribute__((always_inline)) void Eidos_intrusive_ptr_release(const Eid // which should be used for all void values. // -class EidosValue_VOID : public EidosValue +class EidosValue_VOID final : public EidosValue { private: typedef EidosValue super; protected: - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return 0; } public: EidosValue_VOID(const EidosValue_VOID &p_original) = delete; // no copy-construct @@ -378,13 +380,13 @@ class EidosValue_VOID : public EidosValue // representing invisible versus non-invisible NULL. // -class EidosValue_NULL : public EidosValue +class EidosValue_NULL final : public EidosValue { private: typedef EidosValue super; protected: - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return 0; } public: EidosValue_NULL(const EidosValue_NULL &p_original) = delete; // no copy-construct @@ -426,10 +428,10 @@ class EidosValue_NULL : public EidosValue // logical the EidosValue_Logical class itself is a non-abstract class that models a vector of logical // values; there is no singleton version. There is a subclass, EidosValue_Logical_const, that is used // by the two shared T and F EidosValues, gStaticEidosValue_LogicalT and gStaticEidosValue_LogicalF; -// it tries to enforce constness on those globals by making the virtual function LogicalVector_Mutable(), -// which is used to go from an EidosValue* to a EidosValue_Logical*, raise, and by making other virtual +// it tries to enforce constness on those globals by making the virtual function LogicalData_Mutable(), +// which is used to get a mutable pointer to the eidos_logical_t data, raise, and by making other virtual // functions that would modify the value raise as well. This is not entirely bullet-proof, since one -// could cast to EidosValue_Logical instead of using LogicalVector_Mutable(), but you're not supposed +// could cast to EidosValue_Logical instead of using LogicalData_Mutable(), but you're not supposed // to do that. EidosValue_Logical_const pretends to be a singleton class, by setting is_singleton_, // but that is probably non-essential. // @@ -446,7 +448,7 @@ class EidosValue_Logical : public EidosValue protected: explicit EidosValue_Logical(eidos_logical_t p_logical1); // protected to encourage use of EidosValue_Logical_const for this - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return (int)count_; } public: EidosValue_Logical(const EidosValue_Logical &p_original) = delete; // no copy-construct @@ -462,8 +464,8 @@ class EidosValue_Logical : public EidosValue virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; - virtual const EidosValue_Logical *LogicalVector(void) const override { return this; } - virtual EidosValue_Logical *LogicalVector_Mutable(void) override { return this; } + virtual const eidos_logical_t *LogicalData(void) const override { return values_; } + virtual eidos_logical_t *LogicalData_Mutable(void) override { return values_; } virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; @@ -487,7 +489,6 @@ class EidosValue_Logical : public EidosValue inline __attribute__((always_inline)) eidos_logical_t *data(void) { return values_; } inline __attribute__((always_inline)) const eidos_logical_t *data(void) const { return values_; } - inline __attribute__((always_inline)) size_t size(void) const { return count_; } inline __attribute__((always_inline)) void push_logical(eidos_logical_t p_logical) { if (count_ == capacity_) expand(); @@ -509,7 +510,7 @@ class EidosValue_Logical : public EidosValue } }; -class EidosValue_Logical_const : public EidosValue_Logical +class EidosValue_Logical_const final : public EidosValue_Logical { private: typedef EidosValue_Logical super; @@ -529,7 +530,7 @@ class EidosValue_Logical_const : public EidosValue_Logical virtual EidosValue_SP VectorBasedCopy(void) const override; // prohibited actions because this subclass represents only truly immutable objects - virtual EidosValue_Logical *LogicalVector_Mutable(void) override { RaiseForUnimplementedVectorCall(); } + virtual eidos_logical_t *LogicalData_Mutable(void) override { RaiseForUnimplementedVectorCall(); } virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; @@ -577,7 +578,7 @@ class EidosValue_String : public EidosValue virtual void Sort(bool p_ascending) override = 0; }; -class EidosValue_String_vector : public EidosValue_String +class EidosValue_String_vector final : public EidosValue_String { private: typedef EidosValue_String super; @@ -587,7 +588,7 @@ class EidosValue_String_vector : public EidosValue_String // not initializing the memory belonging to a std::string, so the malloc strategy doesn't work std::vector values_; - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return (int)values_.size(); } public: EidosValue_String_vector(const EidosValue_String_vector &p_original) = delete; // no copy-construct @@ -601,8 +602,10 @@ class EidosValue_String_vector : public EidosValue_String explicit EidosValue_String_vector(std::initializer_list p_init_list); inline virtual ~EidosValue_String_vector(void) override { } - virtual const std::vector *StringVector(void) const override { return &values_; } - virtual std::vector *StringVector_Mutable(void) override { return &values_; } + virtual const std::string *StringData(void) const override { return values_.data(); } + virtual std::string *StringData_Mutable(void) override { return values_.data(); } + std::vector &StringVectorData(void) { return values_; } // to get the std::vector for direct modification + inline __attribute__((always_inline)) void PushString(const std::string &p_string) { values_.emplace_back(p_string); } inline __attribute__((always_inline)) EidosValue_String_vector *Reserve(int p_reserved_size) { values_.reserve(p_reserved_size); return this; } @@ -621,7 +624,7 @@ class EidosValue_String_vector : public EidosValue_String virtual void Sort(bool p_ascending) override; }; -class EidosValue_String_singleton : public EidosValue_String +class EidosValue_String_singleton final : public EidosValue_String { private: typedef EidosValue_String super; @@ -630,7 +633,7 @@ class EidosValue_String_singleton : public EidosValue_String std::string value_; EidosScript *cached_script_ = nullptr; // cached by executeLambda(), apply(), and sapply() to avoid multiple tokenize/parse overhead - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return 1; } public: EidosValue_String_singleton(const EidosValue_String_singleton &p_original) = delete; // no copy-construct @@ -639,8 +642,10 @@ class EidosValue_String_singleton : public EidosValue_String explicit inline EidosValue_String_singleton(const std::string &p_string1) : EidosValue_String(true), value_(p_string1) { } inline virtual ~EidosValue_String_singleton(void) override { delete cached_script_; } - inline __attribute__((always_inline)) const std::string &StringValue(void) const { return value_; } inline __attribute__((always_inline)) std::string &StringValue_Mutable(void) { delete cached_script_; cached_script_ = nullptr; return value_; } // very dangerous; do not use + + virtual const std::string *StringData(void) const override { return &value_; } + virtual std::string *StringData_Mutable(void) override { delete cached_script_; cached_script_ = nullptr; return &value_; } // very dangerous; do not use inline __attribute__((always_inline)) void SetValue(const std::string &p_string) { delete cached_script_; cached_script_ = nullptr; value_ = p_string; } // very dangerous; used only in Evaluate_For() virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; @@ -706,7 +711,7 @@ class EidosValue_Int : public EidosValue virtual void Sort(bool p_ascending) override = 0; }; -class EidosValue_Int_vector : public EidosValue_Int +class EidosValue_Int_vector final : public EidosValue_Int { private: typedef EidosValue_Int super; @@ -715,7 +720,7 @@ class EidosValue_Int_vector : public EidosValue_Int int64_t *values_ = nullptr; size_t count_ = 0, capacity_ = 0; - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return (int)count_; } public: EidosValue_Int_vector(const EidosValue_Int_vector &p_original) = delete; // no copy-construct @@ -730,8 +735,8 @@ class EidosValue_Int_vector : public EidosValue_Int explicit EidosValue_Int_vector(const int64_t *p_values, size_t p_count); inline virtual ~EidosValue_Int_vector(void) override { free(values_); } - virtual const EidosValue_Int_vector *IntVector(void) const override { return this; } - virtual EidosValue_Int_vector *IntVector_Mutable(void) override { return this; } + virtual const int64_t *IntData(void) const override { return values_; } + virtual int64_t *IntData_Mutable(void) override { return values_; } virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; @@ -754,7 +759,6 @@ class EidosValue_Int_vector : public EidosValue_Int inline __attribute__((always_inline)) int64_t *data(void) { return values_; } inline __attribute__((always_inline)) const int64_t *data(void) const { return values_; } - inline __attribute__((always_inline)) size_t size(void) const { return count_; } inline __attribute__((always_inline)) void push_int(int64_t p_int) { if (count_ == capacity_) expand(); @@ -776,7 +780,7 @@ class EidosValue_Int_vector : public EidosValue_Int } }; -class EidosValue_Int_singleton : public EidosValue_Int +class EidosValue_Int_singleton final : public EidosValue_Int { private: typedef EidosValue_Int super; @@ -784,7 +788,7 @@ class EidosValue_Int_singleton : public EidosValue_Int protected: int64_t value_; - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return 1; } public: EidosValue_Int_singleton(const EidosValue_Int_singleton &p_original) = delete; // no copy-construct @@ -793,8 +797,8 @@ class EidosValue_Int_singleton : public EidosValue_Int explicit inline EidosValue_Int_singleton(int64_t p_int1) : EidosValue_Int(true), value_(p_int1) { } inline virtual ~EidosValue_Int_singleton(void) override { } - inline __attribute__((always_inline)) int64_t IntValue(void) const { return value_; } - inline __attribute__((always_inline)) int64_t &IntValue_Mutable(void) { return value_; } // very dangerous; used only in Evaluate_Assign() + virtual const int64_t *IntData(void) const override { return &value_; } + virtual int64_t *IntData_Mutable(void) override { return &value_; } // very dangerous; used only in Evaluate_Assign() inline __attribute__((always_inline)) void SetValue(int64_t p_int) { value_ = p_int; } // very dangerous; used only in Evaluate_For() virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; @@ -855,7 +859,7 @@ class EidosValue_Float : public EidosValue virtual void Sort(bool p_ascending) override = 0; }; -class EidosValue_Float_vector : public EidosValue_Float +class EidosValue_Float_vector final : public EidosValue_Float { private: typedef EidosValue_Float super; @@ -864,7 +868,7 @@ class EidosValue_Float_vector : public EidosValue_Float double *values_ = nullptr; size_t count_ = 0, capacity_ = 0; - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return (int)count_; } public: EidosValue_Float_vector(const EidosValue_Float_vector &p_original) = delete; // no copy-construct @@ -877,8 +881,8 @@ class EidosValue_Float_vector : public EidosValue_Float explicit EidosValue_Float_vector(const double *p_values, size_t p_count); inline virtual ~EidosValue_Float_vector(void) override { free(values_); } - virtual const EidosValue_Float_vector *FloatVector(void) const override { return this; } - virtual EidosValue_Float_vector *FloatVector_Mutable(void) override { return this; } + virtual const double *FloatData(void) const override { return values_; } + virtual double *FloatData_Mutable(void) override { return values_; } virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; @@ -901,7 +905,6 @@ class EidosValue_Float_vector : public EidosValue_Float inline __attribute__((always_inline)) double *data(void) { return values_; } inline __attribute__((always_inline)) const double *data(void) const { return values_; } - inline __attribute__((always_inline)) size_t size(void) const { return count_; } inline __attribute__((always_inline)) void push_float(double p_float) { if (count_ == capacity_) expand(); @@ -923,7 +926,7 @@ class EidosValue_Float_vector : public EidosValue_Float } }; -class EidosValue_Float_singleton : public EidosValue_Float +class EidosValue_Float_singleton final : public EidosValue_Float { private: typedef EidosValue_Float super; @@ -931,7 +934,7 @@ class EidosValue_Float_singleton : public EidosValue_Float protected: double value_; - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return 1; } public: EidosValue_Float_singleton(const EidosValue_Float_singleton &p_original) = delete; // no copy-construct @@ -940,8 +943,8 @@ class EidosValue_Float_singleton : public EidosValue_Float explicit inline EidosValue_Float_singleton(double p_float1) : EidosValue_Float(true), value_(p_float1) { } inline virtual ~EidosValue_Float_singleton(void) override { } - inline __attribute__((always_inline)) double FloatValue(void) const { return value_; } - inline __attribute__((always_inline)) double &FloatValue_Mutable(void) { return value_; } // very dangerous; used only in Evaluate_Assign() + virtual const double *FloatData(void) const override { return &value_; } + virtual double *FloatData_Mutable(void) override { return &value_; } // very dangerous; used only in Evaluate_Assign() inline __attribute__((always_inline)) void SetValue(double p_float) { value_ = p_float; } // very dangerous; used only in Evaluate_For() virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; @@ -1046,7 +1049,7 @@ class EidosValue_Object : public EidosValue virtual void PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) = 0; }; -class EidosValue_Object_vector : public EidosValue_Object +class EidosValue_Object_vector final : public EidosValue_Object { private: typedef EidosValue_Object super; @@ -1055,7 +1058,7 @@ class EidosValue_Object_vector : public EidosValue_Object EidosObject **values_ = nullptr; // these may use a retain/release system of ownership; see below size_t count_ = 0, capacity_ = 0; - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return (int)count_; } public: EidosValue_Object_vector(const EidosValue_Object_vector &p_original); // can copy-construct @@ -1074,8 +1077,8 @@ class EidosValue_Object_vector : public EidosValue_Object virtual double FloatAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; virtual EidosObject *ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual const EidosValue_Object_vector *ObjectElementVector(void) const override { return this; } - virtual EidosValue_Object_vector *ObjectElementVector_Mutable(void) override { return this; } + virtual EidosObject * const *ObjectData(void) const override { return values_; } + virtual EidosObject **ObjectData_Mutable(void) override { return values_; } virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; @@ -1105,7 +1108,6 @@ class EidosValue_Object_vector : public EidosValue_Object inline __attribute__((always_inline)) EidosObject **data(void) { return values_; } // the accessors below should be used to modify, since they handle Retain()/Release() inline __attribute__((always_inline)) EidosObject * const *data(void) const { return values_; } - inline __attribute__((always_inline)) size_t size(void) const { return count_; } // fast accessors; you can use the _RR or _NORR versions in a tight loop to avoid overhead, when you know // whether the EidosObject subclass you are using inherits from EidosDictionaryRetained or not; @@ -1302,7 +1304,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ value_slot_to_replace = p_object; } -class EidosValue_Object_singleton : public EidosValue_Object +class EidosValue_Object_singleton final : public EidosValue_Object { private: typedef EidosValue_Object super; @@ -1310,7 +1312,7 @@ class EidosValue_Object_singleton : public EidosValue_Object protected: EidosObject *value_; // these may use a retain/release system of ownership; see below - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return 1; } public: EidosValue_Object_singleton(const EidosValue_Object_singleton &p_original) = delete; // no copy-construct @@ -1326,8 +1328,8 @@ class EidosValue_Object_singleton : public EidosValue_Object virtual double FloatAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; virtual EidosObject *ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - inline __attribute__((always_inline)) EidosObject *ObjectElementValue(void) const { return value_; } - inline __attribute__((always_inline)) EidosObject * &ObjectElementValue_Mutable(void) { return value_; } // very dangerous; do not use + virtual EidosObject * const *ObjectData(void) const override { return &value_; } + virtual EidosObject **ObjectData_Mutable(void) override { return &value_; } // very dangerous; do not use void SetValue(EidosObject *p_element); // very dangerous; used only in Evaluate_For() virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override;