Skip to content

Change fb_strlen to constexpr version #8267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/common/CvtFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,6 @@ namespace
return std::isalpha(static_cast<unsigned char>(symbol));
}

constexpr size_t fb_strlen_constexpr(const char* str)
{
return std::char_traits<char>::length(str);
}

constexpr bool isSeparator(char symbol)
{
switch (symbol)
Expand Down Expand Up @@ -1512,7 +1507,7 @@ namespace
{
// This is deferred pattern
std::string_view period = getSubstringFromString(str, strLength, strOffset,
fb_strlen_constexpr(FormatStr::AM), false);
fb_strlen(FormatStr::AM), false);
deferredTokens.push_back({*it, period});
break;
}
Expand Down
5 changes: 3 additions & 2 deletions src/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#define COMMON_COMMON_H

#include <string.h>
#include <string>

#ifdef HAVE_STDLIB_H
#include <stdlib.h>
Expand Down Expand Up @@ -1026,9 +1027,9 @@ inline const TEXT* const FB_LONG_DAYS_UPPER[] =

const FB_SIZE_T FB_MAX_SIZEOF = ~FB_SIZE_T(0); // Assume FB_SIZE_T is unsigned

inline FB_SIZE_T fb_strlen(const char* str)
inline constexpr FB_SIZE_T fb_strlen(const char* str)
{
return static_cast<FB_SIZE_T>(strlen(str));
return static_cast<FB_SIZE_T>(std::char_traits<char>::length(str));
}

namespace Firebird {
Expand Down
Loading