MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / stringToKey

Method stringToKey

src/common/unicode_util.cpp:1764–1942  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1762
1763
1764USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src,
1765 USHORT dstLen, UCHAR* dst,
1766 USHORT key_type) const
1767{
1768 ULONG srcLenLong = srcLen;
1769
1770 fb_assert(src != NULL && dst != NULL);
1771 fb_assert(srcLenLong % sizeof(*src) == 0);
1772
1773 if (dstLen < keyLength(srcLenLong))
1774 {
1775 fb_assert(false);
1776 return INTL_BAD_KEY_LENGTH;
1777 }
1778
1779 srcLenLong /= sizeof(*src);
1780
1781 if (tt->texttype_pad_option)
1782 {
1783 const USHORT* pad;
1784
1785 for (pad = src + srcLenLong - 1; pad >= src; --pad)
1786 {
1787 if (*pad != 32)
1788 break;
1789 }
1790
1791 srcLenLong = pad - src + 1;
1792 }
1793
1794 if (srcLenLong == 0)
1795 return 0;
1796
1797 HalfStaticArray<USHORT, BUFFER_SMALL / 2> buffer;
1798 const UCollator* coll = NULL;
1799
1800 switch (key_type)
1801 {
1802 case INTL_KEY_PARTIAL:
1803 case INTL_KEY_MULTI_STARTING:
1804 coll = partialCollator;
1805 break;
1806
1807 case INTL_KEY_UNIQUE:
1808 coll = compareCollator;
1809 srcLenLong *= sizeof(*src);
1810 normalize(&srcLenLong, &src, true, buffer);
1811 srcLenLong /= sizeof(*src);
1812 break;
1813
1814 case INTL_KEY_SORT:
1815 coll = sortCollator;
1816 break;
1817
1818 default:
1819 fb_assert(false);
1820 return INTL_BAD_KEY_LENGTH;
1821 }

Callers 1

unicodeStrToKeyFunction · 0.80

Calls 5

getMethod · 0.45
hasDataMethod · 0.45
frontMethod · 0.45
getCountMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected