@@ -102,46 +102,44 @@ class IAnimationLibrary : public virtual core::IReferenceCounted
102
102
//
103
103
inline const SBufferBinding<const BufferType>& getKeyframeStorageBinding () const
104
104
{
105
- return reinterpret_cast <const SBufferBinding<const BufferType>* >(m_keyframeStorageBinding);
105
+ return reinterpret_cast <const SBufferBinding<const BufferType>& >(m_keyframeStorageBinding);
106
106
}
107
107
inline const SBufferBinding<const BufferType>& getTimestampStorageBinding () const
108
108
{
109
- return reinterpret_cast <const SBufferBinding<const BufferType>* >(m_timestampStorageBinding);
109
+ return reinterpret_cast <const SBufferBinding<const BufferType>& >(m_timestampStorageBinding);
110
110
}
111
111
112
112
//
113
113
inline const SBufferRange<const BufferType>& getAnimationStorageRange () const
114
114
{
115
- return reinterpret_cast <const SBufferRange<const BufferType>* >(m_animationStorageRange);
115
+ return reinterpret_cast <const SBufferRange<const BufferType>& >(m_animationStorageRange);
116
116
}
117
117
118
118
//
119
119
inline uint32_t getAnimationCapacity () const
120
120
{
121
- return m_animationStorageRange.size () / sizeof (Animation);
121
+ return m_animationStorageRange.size / sizeof (Animation);
122
122
}
123
123
124
124
inline uint32_t getAnimationOffsetFromName (const char * animationName) const
125
125
{
126
- auto found = m_nameToAnimation.find (animationName);
126
+ m_temporaryString = animationName;
127
+ auto found = m_nameToAnimation.find (0xffffffffu );
128
+ m_temporaryString = nullptr ;
127
129
if (found != m_nameToAnimation.end ())
128
130
return found->second ;
129
131
return getAnimationCapacity ();
130
132
}
131
133
132
- inline const auto & getNameToAnimationMap () const
133
- {
134
- return m_nameToAnimation;
135
- }
136
-
137
134
138
135
protected:
139
136
IAnimationLibrary (SBufferBinding<BufferType>&& _keyframeStorageBinding, SBufferBinding<BufferType>&& _timestampStorageBinding, uint32_t _keyframeCount, SBufferRange<BufferType>&& _animationStorageRange) :
140
- m_stringPool (), m_nameToAnimation(StringComparator(&m_stringPool)), m_keyframeStorageBinding(std::move(_keyframeStorageBinding)), m_timestampStorageBinding(std::move(_timestampStorageBinding)),
137
+ m_stringPool (), m_temporaryString(nullptr ), m_nameToAnimation(StringComparator(&m_stringPool,&m_temporaryString)),
138
+ m_keyframeStorageBinding (std::move(_keyframeStorageBinding)), m_timestampStorageBinding(std::move(_timestampStorageBinding)),
141
139
m_animationStorageRange (std::move(_animationStorageRange)), m_keyframeCount(_keyframeCount)
142
140
{
143
- assert (m_keyframeStorageBinding.buffer && (m_keyframeStorageBinding. offset % sizeof (Keyframe)== 0u ) && m_keyframeStorageBinding.offset +sizeof (Keyframe)*m_keyframeCount<=m_keyframeStorageBinding.buffer ->getSize ());
144
- assert (m_timestampStorageBinding.buffer && (m_timestampStorageBinding. offset % sizeof (Keyframe)== 0u ) && m_timestampStorageBinding.offset +sizeof (timestamp_t )*m_keyframeCount<=m_timestampStorageBinding.buffer ->getSize ());
141
+ assert (m_keyframeStorageBinding.buffer && m_keyframeStorageBinding.offset +sizeof (Keyframe)*m_keyframeCount<=m_keyframeStorageBinding.buffer ->getSize ());
142
+ assert (m_timestampStorageBinding.buffer && m_timestampStorageBinding.offset +sizeof (timestamp_t )*m_keyframeCount<=m_timestampStorageBinding.buffer ->getSize ());
145
143
146
144
if (!m_animationStorageRange.isValid ())
147
145
return ;
@@ -204,17 +202,21 @@ class IAnimationLibrary : public virtual core::IReferenceCounted
204
202
205
203
struct StringComparator
206
204
{
207
- StringComparator (const core::vector<char >* const _stringPool) : stringPool(_stringPool) {}
205
+ StringComparator (const core::vector<char >* const _stringPool, const char * const * _temporaryString ) : stringPool(_stringPool), temporaryString(_temporaryString ) {}
208
206
209
- inline bool operator ()(const uint32_t lhs , const uint32_t rhs ) const
207
+ inline bool operator ()(const uint32_t _lhs , const uint32_t _rhs ) const
210
208
{
211
- return strcmp (stringPool->data ()+lhs,stringPool->data ()+rhs)<0 ;
209
+ const char * lhs = _lhs!=0xffffffffu ? (stringPool->data ()+_lhs):(*temporaryString);
210
+ const char * rhs = _rhs!=0xffffffffu ? (stringPool->data ()+_rhs):(*temporaryString);
211
+ return strcmp (lhs,rhs)<0 ;
212
212
}
213
213
214
214
private:
215
215
const core::vector<char >* stringPool;
216
+ const char * const * temporaryString;
216
217
};
217
218
core::vector<char > m_stringPool;
219
+ mutable const char * m_temporaryString;
218
220
core::map<uint32_t ,uint32_t ,StringComparator> m_nameToAnimation;
219
221
220
222
SBufferBinding<BufferType> m_keyframeStorageBinding,m_timestampStorageBinding;
0 commit comments