MCPcopy Create free account
hub / github.com/Snapchat/Valdi / preprocess

Method preprocess

valdi/src/valdi/runtime/Attributes/AttributeHandler.cpp:90–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 return result.error().rethrow(STRING_FORMAT("Failed to preprocess value {}", _name, value.toString()));
89 }
90 current = result.moveValue();
91 }
92 }
93
94 return current;
95}
96
97Result<PreprocessedValue> AttributeHandler::preprocess(const Value& value) const {
98 if (VALDI_LIKELY(_preprocessingTrivial)) {
99 if (_preprocessors.empty()) {
100 return PreprocessedValue(value);
101 }
102
103 auto result = preprocessWithoutCache(value);
104 if (!result) {
105 return result.moveError();
106 }
107 return PreprocessedValue(result.moveValue());
108 }
109
110 if (_preprocessorCache != nullptr) {
111 auto cacheKey = PreprocessorCacheKey(value);
112
113 auto result = _preprocessorCache->get(cacheKey);
114 if (result) {
115 return *result;
116 }
117
118 auto preprocessResult = preprocessWithoutCache(value);
119 if (!preprocessResult) {
120 return preprocessResult.moveError();
121 }
122
123 return _preprocessorCache->store(cacheKey, preprocessResult.moveValue());
124 } else {
125 auto result = preprocessWithoutCache(value);
126 if (!result) {
127 return result.moveError();

Callers 4

marshallMethod · 0.45
preprocessValueMethod · 0.45
setFunction · 0.45
toNativeDirectFunction · 0.45

Calls 5

PreprocessedValueClass · 0.85
getMethod · 0.65
storeMethod · 0.65
emptyMethod · 0.45

Tested by

no test coverage detected