41
41
#else
42
42
namespace
43
43
{
44
- int StringIgnoreCaseCompare (const char * s1, const char * s2, unsigned int l)
44
+ int StringIgnoreCaseCompare (const char * s1, const char * s2, unsigned int l) noexcept
45
45
{
46
46
while (l--)
47
47
{
@@ -61,11 +61,10 @@ namespace {
61
61
class strBitMask
62
62
{
63
63
private:
64
- char m[32 ];
64
+ char m[32 ]{} ;
65
65
public:
66
- strBitMask (Firebird::AbstractString::const_pointer s, Firebird::AbstractString::size_type l)
66
+ strBitMask (Firebird::AbstractString::const_pointer s, Firebird::AbstractString::size_type l) noexcept
67
67
{
68
- memset (m, 0 , sizeof (m));
69
68
if (l == Firebird::AbstractString::npos) {
70
69
l = static_cast <Firebird::AbstractString::size_type>(strlen (s));
71
70
}
@@ -76,7 +75,8 @@ namespace {
76
75
m[uc >> 3 ] |= (1 << (uc & 7 ));
77
76
}
78
77
}
79
- inline bool Contains (const char c) const
78
+
79
+ inline bool Contains (const char c) const noexcept
80
80
{
81
81
const unsigned char uc = static_cast <unsigned char >(c);
82
82
return m[uc >> 3 ] & (1 << (uc & 7 ));
@@ -203,9 +203,9 @@ namespace Firebird
203
203
shrinkBuffer ();
204
204
}
205
205
206
- AbstractString::size_type AbstractString::rfind (const_pointer s, const size_type pos) const
206
+ AbstractString::size_type AbstractString::rfind (const_pointer s, const size_type pos) const noexcept
207
207
{
208
- const size_type l = static_cast <size_type>( strlen (s) );
208
+ const size_type l = length (s );
209
209
int lastpos = length () - l;
210
210
if (lastpos < 0 ) {
211
211
return npos;
@@ -223,7 +223,7 @@ namespace Firebird
223
223
return npos;
224
224
}
225
225
226
- AbstractString::size_type AbstractString::rfind (char_type c, const size_type pos) const
226
+ AbstractString::size_type AbstractString::rfind (char_type c, const size_type pos) const noexcept
227
227
{
228
228
int lastpos = length () - 1 ;
229
229
if (lastpos < 0 ) {
@@ -242,7 +242,7 @@ namespace Firebird
242
242
return npos;
243
243
}
244
244
245
- AbstractString::size_type AbstractString::find_first_of (const_pointer s, size_type pos, size_type n) const
245
+ AbstractString::size_type AbstractString::find_first_of (const_pointer s, size_type pos, size_type n) const noexcept
246
246
{
247
247
const strBitMask sm (s, n);
248
248
const_pointer p = &c_str ()[pos];
@@ -256,7 +256,7 @@ namespace Firebird
256
256
return npos;
257
257
}
258
258
259
- AbstractString::size_type AbstractString::find_last_of (const_pointer s, const size_type pos, size_type n) const
259
+ AbstractString::size_type AbstractString::find_last_of (const_pointer s, const size_type pos, size_type n) const noexcept
260
260
{
261
261
const strBitMask sm (s, n);
262
262
int lpos = length () - 1 ;
@@ -274,7 +274,7 @@ namespace Firebird
274
274
return npos;
275
275
}
276
276
277
- AbstractString::size_type AbstractString::find_first_not_of (const_pointer s, size_type pos, size_type n) const
277
+ AbstractString::size_type AbstractString::find_first_not_of (const_pointer s, size_type pos, size_type n) const noexcept
278
278
{
279
279
const strBitMask sm (s, n);
280
280
const_pointer p = &c_str ()[pos];
@@ -288,7 +288,7 @@ namespace Firebird
288
288
return npos;
289
289
}
290
290
291
- AbstractString::size_type AbstractString::find_last_not_of (const_pointer s, const size_type pos, size_type n) const
291
+ AbstractString::size_type AbstractString::find_last_not_of (const_pointer s, const size_type pos, size_type n) const noexcept
292
292
{
293
293
const strBitMask sm (s, n);
294
294
int lpos = length () - 1 ;
@@ -357,16 +357,16 @@ extern "C" {
357
357
#endif // WIN_NT
358
358
}
359
359
360
- void AbstractString::baseTrim (const TrimType whereTrim, const_pointer toTrim)
360
+ void AbstractString::baseTrim (const TrimType whereTrim, const_pointer toTrim) noexcept
361
361
{
362
- const strBitMask sm (toTrim, static_cast <size_type>( strlen ( toTrim) ));
362
+ const strBitMask sm (toTrim, length ( toTrim));
363
363
const_pointer b = c_str ();
364
364
const_pointer e = c_str () + length () - 1 ;
365
365
if (whereTrim != TrimRight)
366
366
{
367
367
while (b <= e)
368
368
{
369
- if (! sm.Contains (*b)) {
369
+ if (!sm.Contains (*b)) {
370
370
break ;
371
371
}
372
372
++b;
@@ -376,7 +376,7 @@ extern "C" {
376
376
{
377
377
while (b <= e)
378
378
{
379
- if (! sm.Contains (*e)) {
379
+ if (!sm.Contains (*e)) {
380
380
break ;
381
381
}
382
382
--e;
@@ -396,7 +396,7 @@ extern "C" {
396
396
shrinkBuffer ();
397
397
}
398
398
399
- bool AbstractString::baseMove (AbstractString&& rhs)
399
+ bool AbstractString::baseMove (AbstractString&& rhs) noexcept
400
400
{
401
401
if (getPool () == rhs.getPool () && rhs.inlineBuffer != rhs.stringBuffer )
402
402
{
@@ -476,7 +476,7 @@ extern "C" {
476
476
}
477
477
}
478
478
479
- unsigned int AbstractString::hash (const_pointer string, const size_type tableSize)
479
+ unsigned int AbstractString::hash (const_pointer string, const size_type tableSize) noexcept
480
480
{
481
481
unsigned int value = 0 ;
482
482
unsigned char c;
@@ -490,18 +490,14 @@ extern "C" {
490
490
return value % tableSize;
491
491
}
492
492
493
- bool AbstractString::equalsNoCase (AbstractString::const_pointer string) const
493
+ bool AbstractString::equalsNoCase (AbstractString::const_pointer string) const noexcept
494
494
{
495
- size_t l = strlen (string);
496
- if (l > length ())
497
- {
498
- l = length ();
499
- }
495
+ size_t l = MIN (strlen (string), length ());
500
496
return (STRNCASECMP (c_str (), string, ++l) == 0 );
501
497
}
502
498
503
499
int PathNameComparator::compare (AbstractString::const_pointer s1, AbstractString::const_pointer s2,
504
- const AbstractString::size_type n)
500
+ const AbstractString::size_type n) noexcept
505
501
{
506
502
if (CASE_SENSITIVITY)
507
503
return memcmp (s1, s2, n);
@@ -510,7 +506,7 @@ extern "C" {
510
506
}
511
507
512
508
int IgnoreCaseComparator::compare (AbstractString::const_pointer s1, AbstractString::const_pointer s2,
513
- const AbstractString::size_type n)
509
+ const AbstractString::size_type n) noexcept
514
510
{
515
511
return STRNCASECMP (s1, s2, n);
516
512
}
0 commit comments