aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/XML/src/NamePool.cpp
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:45:01 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:01 +0300
commit2d37894b1b037cf24231090eda8589bbb44fb6fc (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/poco/XML/src/NamePool.cpp
parent718c552901d703c502ccbefdfc3c9028d608b947 (diff)
downloadydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/poco/XML/src/NamePool.cpp')
-rw-r--r--contrib/libs/poco/XML/src/NamePool.cpp264
1 files changed, 132 insertions, 132 deletions
diff --git a/contrib/libs/poco/XML/src/NamePool.cpp b/contrib/libs/poco/XML/src/NamePool.cpp
index 386aab5eb7..4e234eabf9 100644
--- a/contrib/libs/poco/XML/src/NamePool.cpp
+++ b/contrib/libs/poco/XML/src/NamePool.cpp
@@ -1,132 +1,132 @@
-//
-// NamePool.cpp
-//
-// Library: XML
-// Package: XML
-// Module: NamePool
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/XML/NamePool.h"
-#include "Poco/Exception.h"
-#include "Poco/Random.h"
-
-
-namespace Poco {
-namespace XML {
-
-
-class NamePoolItem
-{
-public:
- NamePoolItem(): _used(false)
- {
- }
-
- ~NamePoolItem()
- {
- }
-
- bool set(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName)
- {
- if (!_used)
- {
- _name.assign(qname, namespaceURI, localName);
- _used = true;
- return true;
- }
- else return _name.equals(qname, namespaceURI, localName);
- }
-
- const Name& get() const
- {
- return _name;
- }
-
- bool used() const
- {
- return _used;
- }
-
-private:
- Name _name;
- bool _used;
-};
-
-
-NamePool::NamePool(unsigned long size):
- _size(size),
- _salt(0),
- _rc(1)
-{
- poco_assert (size > 1);
-
- _pItems = new NamePoolItem[size];
-
- Poco::Random rnd;
- rnd.seed();
- _salt = rnd.next();
-}
-
-
-NamePool::~NamePool()
-{
- delete [] _pItems;
-}
-
-
-void NamePool::duplicate()
-{
- ++_rc;
-}
-
-
-void NamePool::release()
-{
- if (--_rc == 0)
- delete this;
-}
-
-
-const Name& NamePool::insert(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName)
-{
- unsigned long i = 0;
- unsigned long n = (hash(qname, namespaceURI, localName) ^ _salt) % _size;
-
- while (!_pItems[n].set(qname, namespaceURI, localName) && i++ < _size)
- n = (n + 1) % _size;
-
- if (i > _size) throw Poco::PoolOverflowException("XML name pool");
-
- return _pItems[n].get();
-}
-
-
-const Name& NamePool::insert(const Name& name)
-{
- return insert(name.qname(), name.namespaceURI(), name.localName());
-}
-
-
-unsigned long NamePool::hash(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName)
-{
- unsigned long h = 0;
- XMLString::const_iterator it = qname.begin();
- XMLString::const_iterator end = qname.end();
- while (it != end) h = (h << 5) + h + (unsigned long) *it++;
- it = namespaceURI.begin();
- end = namespaceURI.end();
- while (it != end) h = (h << 5) + h + (unsigned long) *it++;
- it = localName.begin();
- end = localName.end();
- while (it != end) h = (h << 5) + h + (unsigned long) *it++;
- return h;
-}
-
-
-} } // namespace Poco::XML
+//
+// NamePool.cpp
+//
+// Library: XML
+// Package: XML
+// Module: NamePool
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/XML/NamePool.h"
+#include "Poco/Exception.h"
+#include "Poco/Random.h"
+
+
+namespace Poco {
+namespace XML {
+
+
+class NamePoolItem
+{
+public:
+ NamePoolItem(): _used(false)
+ {
+ }
+
+ ~NamePoolItem()
+ {
+ }
+
+ bool set(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName)
+ {
+ if (!_used)
+ {
+ _name.assign(qname, namespaceURI, localName);
+ _used = true;
+ return true;
+ }
+ else return _name.equals(qname, namespaceURI, localName);
+ }
+
+ const Name& get() const
+ {
+ return _name;
+ }
+
+ bool used() const
+ {
+ return _used;
+ }
+
+private:
+ Name _name;
+ bool _used;
+};
+
+
+NamePool::NamePool(unsigned long size):
+ _size(size),
+ _salt(0),
+ _rc(1)
+{
+ poco_assert (size > 1);
+
+ _pItems = new NamePoolItem[size];
+
+ Poco::Random rnd;
+ rnd.seed();
+ _salt = rnd.next();
+}
+
+
+NamePool::~NamePool()
+{
+ delete [] _pItems;
+}
+
+
+void NamePool::duplicate()
+{
+ ++_rc;
+}
+
+
+void NamePool::release()
+{
+ if (--_rc == 0)
+ delete this;
+}
+
+
+const Name& NamePool::insert(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName)
+{
+ unsigned long i = 0;
+ unsigned long n = (hash(qname, namespaceURI, localName) ^ _salt) % _size;
+
+ while (!_pItems[n].set(qname, namespaceURI, localName) && i++ < _size)
+ n = (n + 1) % _size;
+
+ if (i > _size) throw Poco::PoolOverflowException("XML name pool");
+
+ return _pItems[n].get();
+}
+
+
+const Name& NamePool::insert(const Name& name)
+{
+ return insert(name.qname(), name.namespaceURI(), name.localName());
+}
+
+
+unsigned long NamePool::hash(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName)
+{
+ unsigned long h = 0;
+ XMLString::const_iterator it = qname.begin();
+ XMLString::const_iterator end = qname.end();
+ while (it != end) h = (h << 5) + h + (unsigned long) *it++;
+ it = namespaceURI.begin();
+ end = namespaceURI.end();
+ while (it != end) h = (h << 5) + h + (unsigned long) *it++;
+ it = localName.begin();
+ end = localName.end();
+ while (it != end) h = (h << 5) + h + (unsigned long) *it++;
+ return h;
+}
+
+
+} } // namespace Poco::XML