Hello,

For each character key typed, two conversions occurs:

lyxfunc.C: 324
        if (func.action == LFUN_SELF_INSERT) {
                if (encoded_last_key != 0) {
                        std::vector<char> tmp =
                                ucs4_to_utf8(encoded_last_key);
                        string const arg(tmp.begin(), tmp.end());
                        dispatch(FuncRequest(LFUN_SELF_INSERT, arg,
                                             FuncRequest::KEYBOARD));

and text3.C: 1104
        std::vector<char> in(cmd.argument.begin(), cmd.argument.end());
        std::vector<boost::uint32_t> const res = utf8_to_ucs4(in);
        std::vector<boost::uint32_t>::const_iterator cit = res.begin();
        std::vector<boost::uint32_t>::const_iterator end = res.end();
        for (; cit != end; ++cit)
                insertChar(bv->cursor(), *cit);

This back and forth conversion to utf8 is obviously extraneous and should be deleted. We have two solutions:

1) use something else that FuncRequest::argument to store the characters to be inserted. I am thinking of a new member data_ accessible through data(). Question is docstring or vector<char_type>? (As a side note, I really don't understand why we still have to make this choice up until now.)

2) convert "argument" to docstring (or vector<char_type>, pfiou...). This would be the ideal solution but this would affect a _lot_ of code.

Personnally I'd opt for solution 1. It has the advantage of a step by step migration from FuncRequest::argument to FuncRequest::data().

Opinions?

Abdel.


Reply via email to