Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions inflection/src/inflection/dialog/CommonConceptFactoryImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,9 @@ SpeakableString* CommonConceptFactoryImpl::quantify(const NumberConcept& number,
{
::std::unique_ptr<SpeakableString> formattedNumber;
if (semanticFeatureForNumberConcept != nullptr) {
auto speakableFeatureValue = npc(semanticConcept)->getFeatureValue(*npc(semanticFeatureForNumberConcept));
if (speakableFeatureValue != nullptr) {
auto rulename = semanticFeatureToNumberConceptName.find(npc(speakableFeatureValue)->getPrint());
delete speakableFeatureValue;
::std::unique_ptr<SpeakableString> speakableFeatureValue(npc(semanticConcept)->getFeatureValue(*npc(semanticFeatureForNumberConcept)));
if (speakableFeatureValue.get() != nullptr) {
auto rulename = semanticFeatureToNumberConceptName.find(speakableFeatureValue->getPrint());
if (rulename != semanticFeatureToNumberConceptName.end()) {
formattedNumber.reset(new SpeakableString(number.asSpokenWords(rulename->second)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ int32_t DefinitenessDisplayFunction::getArticlePrefixLength(DisplayValue* origin
DisplayValue*
DefinitenessDisplayFunction::replaceDisplayValue(DisplayValue* originalDisplayValue, const SpeakableString& string) const
{
auto displayValueConstraints(npc(originalDisplayValue)->getConstraintMap());
::std::unique_ptr<DisplayValue> value(npc(originalDisplayValue));
auto displayValueConstraints(value->getConstraintMap());
if (!string.speakEqualsPrint()) {
displayValueConstraints[*npc(speakFeature)] = string.getSpeak();
}
auto newValue = new DisplayValue(string.getPrint(), displayValueConstraints);
delete originalDisplayValue;
return newValue;
value.reset(new DisplayValue(string.getPrint(), displayValueConstraints));
return value.release();
}

DisplayValue*
Expand Down
7 changes: 3 additions & 4 deletions inflection/src/inflection/dialog/SemanticConceptList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,11 @@ std::u16string SemanticConceptList::toString() const
if (previousConcept != nullptr) {
displayValue += comma;
}
auto conceptResult = npc(conceptObj)->toSpeakableString();
if (conceptResult != nullptr) {
displayValue += *npc(conceptResult);
::std::unique_ptr<::inflection::dialog::SpeakableString> conceptResult(npc(conceptObj)->toSpeakableString());
if (conceptResult.get() != nullptr) {
displayValue += *conceptResult;
}
previousConcept = conceptObj;
delete conceptResult;
}
return u"[" + displayValue.getPrint() + u"]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ DictionaryMetaData_MMappedDictionary::DictionaryMetaData_MMappedDictionary(::inf

DictionaryMetaData_MMappedDictionary::~DictionaryMetaData_MMappedDictionary()
{
delete inflector;
delete memoryMappedRegion;
}

const ::inflection::util::ULocale& DictionaryMetaData_MMappedDictionary::getLocale() const
Expand Down Expand Up @@ -189,11 +187,11 @@ bool DictionaryMetaData_MMappedDictionary::getWordPropertyValues(::std::vector<:
return true;
}

const bool useInflectionTrieForKeys = (inflector != nullptr) && (propertyNameIdentifier == inflectionKeyIdentifier);
const bool useInflectionTrieForKeys = (inflector.get() != nullptr) && (propertyNameIdentifier == inflectionKeyIdentifier);

for (const auto propertyIdentifier: propertyIdentifiers) {
npc(result)->emplace_back(useInflectionTrieForKeys
? npc(inflector)->mmappedDictionary.identifierToInflectionPatternTrie.getKey(propertyIdentifier)
? inflector->mmappedDictionary.identifierToInflectionPatternTrie.getKey(propertyIdentifier)
: propertyValuesStringContainer.getString(propertyIdentifier));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class INFLECTION_INTERNAL_API inflection::dictionary::DictionaryMetaData_MMapped
::inflection::dictionary::metadata::StringArrayContainer propertyNameToKeyId { };
::inflection::dictionary::metadata::StringContainer propertyValuesStringContainer { };
::inflection::dictionary::metadata::CompressedArray<int32_t> propertyValueMaps {::std::vector<int32_t>()};
::inflection::dictionary::Inflector* inflector { };
::inflection::util::MemoryMappedFile* memoryMappedRegion { };
::std::unique_ptr<::inflection::dictionary::Inflector> inflector { };
::std::unique_ptr<::inflection::util::MemoryMappedFile> memoryMappedRegion { };
int32_t inflectionKeyIdentifier { -1 };
int32_t bitsPropertyValueMapKeyMask { };
int32_t bitsPropertyValueMapKeySize { };
Expand Down
2 changes: 1 addition & 1 deletion inflection/src/inflection/dictionary/Inflector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace inflection::dictionary {

const Inflector& Inflector::getInflector(const ::inflection::util::ULocale &locale) {
const Inflector* result = npc(DictionaryMetaData::createDictionary(locale))->dictionary->inflector;
const Inflector* result = npc(DictionaryMetaData::createDictionary(locale))->dictionary->inflector.get();
if (result == nullptr) {
throw ::inflection::exception::NullPointerException(inflection::util::StringViewUtils::to_u16string("Inflector not found for " + locale.getName()));
}
Expand Down
1 change: 1 addition & 0 deletions inflection/src/inflection/dictionary/Inflector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class inflection::dictionary::Inflector
private:
explicit Inflector(inflection::util::MemoryMappedFile& memoryMappedFile, const ::std::u16string& sourcePath, const ::inflection::dictionary::DictionaryMetaData_MMappedDictionary &dictionary);

public:
~Inflector() override;

private:
Expand Down
8 changes: 4 additions & 4 deletions inflection/src/inflection/lang/StringFilterUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,18 @@ static ::std::map<const ::icu4cxx::UnicodeSet*, const ::icu4cxx::UnicodeSet*>* S
return setSingletons_;
}

const icu4cxx::UnicodeSet* StringFilterUtil::getSetSingleton(::icu4cxx::UnicodeSet* set)
const icu4cxx::UnicodeSet* StringFilterUtil::getSetSingleton(::icu4cxx::UnicodeSet* input)
{
// TODO: this code probably doesn't work that well anymore. We should check the caching again.
auto setSingletons = SET_SINGLETONS();
const icu4cxx::UnicodeSet* singleton;
auto singletonCache = npc(setSingletons)->find(set);
::std::unique_ptr<::icu4cxx::UnicodeSet> set(input);
auto singletonCache = npc(setSingletons)->find(set.get());
if (singletonCache == npc(setSingletons)->end()) {
singleton = ::inflection::util::UnicodeSetUtils::freeze(set);
singleton = ::inflection::util::UnicodeSetUtils::freeze(set.release());
npc(setSingletons)->emplace(singleton, singleton);
}
else {
delete set;
singleton = singletonCache->second;
}
return singleton;
Expand Down
Loading