FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

make detect encoding functions constexpr by shikharish · Pull Request #920 · simdutf/simdutf · GitHub

make detect encoding functions constexpr - #920

Open
shikharish wants to merge 6 commits into
simdutf:masterfrom
shikharish:encoding-constexpr
Open

make detect encoding functions constexpr#920
shikharish wants to merge 6 commits into
simdutf:masterfrom
shikharish:encoding-constexpr

Conversation

Copy link
Copy Markdown
Contributor

Closes #891

Signed-off-by: Shikhar <shikharish05@gmail.com>
Signed-off-by: Shikhar <shikharish05@gmail.com>

Copy link
Copy Markdown
Contributor Author

cc: @lemire @pauldreik

lemire commented Jan 13, 2026

Copy link
Copy Markdown
Member

@shikharish thanks. This will nicely close our gap. Let us include this in our next release.

pauldreik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for the PR! I am in a hurry so sorry for not doing a thorough review.
I think it is mostly fine but I have some questions.

Comment thread include/simdutf/common_defs.h Outdated
Comment thread include/simdutf/compiler_check.h Outdated
Comment thread include/simdutf/encoding_types.h Outdated
simdutf_warn_unused encoding_type check_bom(const uint8_t *byte, size_t length);
simdutf_warn_unused encoding_type check_bom(const char *byte, size_t length);
template <typename BytePtr>
simdutf_warn_unused inline simdutf_constexpr14 encoding_type

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

let's use a macro guarded c++20 concept here to restrict the bytepr.

Comment thread include/simdutf/encoding_types.h Outdated
return encoding_type::unspecified;
}

simdutf_warn_unused inline encoding_type check_bom(const char *byte,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

should be really_inline

Comment thread include/simdutf/implementation.h Outdated
#include <simdutf/scalar/utf32_to_utf8/utf32_to_utf8.h>
#include <simdutf/scalar/utf32_to_utf8/valid_utf32_to_utf8.h>
#include <simdutf/scalar/utf8.h>
#include <simdutf/scalar/detect.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

why is this included twice?

Comment on lines +132 to +135
#include <simdutf/scalar/utf8.h>
#include <simdutf/scalar/utf16.h>
#include <simdutf/scalar/utf32.h>
#include <simdutf/scalar/detect.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

it is ok to move around the includes, but remove those that are duplicates

#include <simdutf/scalar/utf32.h>
#include <simdutf/scalar/detect.h>

#if SIMDUTF_SPAN

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

why is this needed?

* of units processed if successful.
*/
simdutf_warn_unused result
simdutf_warn_unused simdutf_constexpr23 result

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

why was this changed?

Comment thread tests/autodetect_constexpr_tests.cpp Outdated
}

template <endianness big_endian>
template <endianness big_endian, typename InputPtr>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

please add a macro guarded c++20 concept check.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

(and reused the already existing concept and style)

Signed-off-by: Shikhar <shikharish05@gmail.com>
Signed-off-by: Shikhar <shikharish05@gmail.com>

lemire commented Jan 16, 2026

Copy link
Copy Markdown
Member

@shikharish Could you have a look at @pauldreik's comments ? There are a few that are apparently outstanding (meaning that it is unclear whether you answered or changed the code accordingly).

Copy link
Copy Markdown
Contributor Author

@lemire I made all the requested changes. There were a few things I misunderstood before but I've fixed them in the last few commits.

lemire commented Jan 16, 2026

Copy link
Copy Markdown
Member

@pauldreik Can you check that your concerns were addressed?

Comment thread include/simdutf/encoding_types.h Outdated
#if SIMDUTF_CPLUSPLUS20
#include <concepts>
template <typename BytePtr>
concept check_bom_byteptr = requires(BytePtr p, size_t i) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

please look at the other constexpr changes recently merged and reuse the already existing concepts.

}

template <endianness big_endian>
template <endianness big_endian, typename InputPtr>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

(and reused the already existing concept and style)

Comment thread tests/autodetect_constexpr_tests.cpp Outdated
Signed-off-by: Shikhar <shikharish05@gmail.com>
shikharish requested a review from pauldreik January 21, 2026 11:39

Copy link
Copy Markdown
Contributor Author

@pauldreik Please review.

Copy link
Copy Markdown
Collaborator

@shikharish when you get review comments, please go through them one by one and fix/answer them. otherwise I have to go through everything again. there are still issues left from earlier comments.

what is also left to do:

  • update the README which says these two functions miss constexpr functionality.
  • a function template is already implicitly inline, don't mark as inline.
  • the changes in base64, why are they there? surprised to see them in this PR.

Comment thread tests/autodetect_constexpr_tests.cpp Outdated
Comment on lines +2 to +3
#include <iostream>
#include <array>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

these don't seem to be used.

Comment thread include/simdutf/scalar/utf16.h Outdated
Comment on lines +20 to +24
#if SIMDUTF_SPAN
template <endianness big_endian, simdutf::detail::indexes_into_utf16 InputPtr>
#else
template <endianness big_endian, typename InputPtr>
#endif

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
template <endianness big_endian, typename InputPtr>
#if SIMDUTF_CPLUSPLUS20
  requires simdutf::detail::indexes_into_utf16<InputPtr>
#endif
simdutf_warn_unused simdutf_constexpr23 bool

Comment thread include/simdutf/scalar/utf16.h Outdated
}

template <endianness big_endian>
inline simdutf_warn_unused simdutf_constexpr23 bool

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

this should be a simdutf really inline

Signed-off-by: Shikhar <shikharish05@gmail.com>

lemire commented Apr 6, 2026

Copy link
Copy Markdown
Member

@shikharish Could you have a look at the comments ?

Copy link
Copy Markdown
Contributor Author

@lemire The last commit addressed all the previous comments.

lemire commented Apr 14, 2026

Copy link
Copy Markdown
Member

@shikharish Ok, can you access the web interface at #920 and look at @pauldreik's comments. For each one of them, can you reply to Paul. It can be as simple as 'ok, I did it in my last commit', and so forth.

Otherwise, we have to go through all the comments and cross-reference them with you code changes and make sure that they have been addressed. It should be far easier for you to check each comment and confirm that it was addressed, with explanations where necessary.

Thanks!!!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make immediate versions of autodetect_encoding and detect_encodings (constexpr)

3 participants


Back | FazBrowse Home | New Git URL