Commit 568f8d28 authored by Hiroshi Sumita's avatar Hiroshi Sumita
Browse files

Change the API to fetch candidates incrementally.

BUG=Conversion is slow
TEST=Test manually with client applications.

Review URL: https://codereview.appspot.com/6073043
parent b017ae7d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ m4_define([pyzy_released], [1])

m4_define([pyzy_major_version], [0])
m4_define([pyzy_minor_version], [0])
m4_define([pyzy_micro_version], [1])
m4_define([pyzy_micro_version], [2])
m4_define([pyzy_interface_age], [0])
m4_define([pyzy_binary_age],
          [m4_eval(100 * pyzy_minor_version + pyzy_micro_version)])
+0 −2
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ libpyzy_built_h_sources = \
libpyzy_c_sources = \
	PyZyInputContext.cc \
	PyZyBopomofoContext.cc \
        PyZyCandidates.cc \
	PyZyConfig.cc \
	PyZyDatabase.cc \
	PyZyDoublePinyinContext.cc \
@@ -71,7 +70,6 @@ libpyzy_h_sources = \
	PyZyInputContext.h \
	PyZyBopomofo.h \
	PyZyBopomofoContext.h \
        PyZyCandidates.h \
	PyZyConfig.h \
	PyZyDatabase.h \
	PyZyDoublePinyinContext.h \
+2 −3
Original line number Diff line number Diff line
@@ -261,8 +261,7 @@ BopomofoContext::updatePinyin (void)
void
BopomofoContext::updateAuxiliaryText (void)
{
    if (G_UNLIKELY (m_text.empty () ||
        m_phrase_editor.candidates ().size () == 0)) {
    if (G_UNLIKELY (m_text.empty () || !hasCandidate (0))) {
        m_auxiliary_text = "";
        PhoneticContext::updateAuxiliaryText ();
        return;
@@ -382,7 +381,7 @@ BopomofoContext::updatePreeditText (void)
        edit_begin_word = m_buffer.utf8Length ();
        edit_begin_byte = m_buffer.size ();

        if (m_candidates.size () > 0) {
        if (hasCandidate (0)) {
            size_t index = m_focused_candidate;

            if (index < m_special_phrases.size ()) {

src/PyZyCandidates.cc

deleted100644 → 0
+0 −48
Original line number Diff line number Diff line
/* vim:set et ts=4 sts=4:
 *
 * libpyzy - The Chinese PinYin and Bopomofo conversion library.
 *
 * Copyright (c) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of the
 * License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

#include "PyZyCandidates.h"

namespace PyZy {

ConcreteCandidates::~ConcreteCandidates () {
}

const Candidate & ConcreteCandidates::get (size_t index) const {
  return m_candidates[index];
}

const size_t ConcreteCandidates::size () const {
  // TODO(hsumita): replace it.
  // return m_size;
  return m_candidates.size ();
}

void ConcreteCandidates::clear() {
  m_candidates.clear ();
}

void ConcreteCandidates::push_back (const Candidate &candidate) {
  m_candidates.push_back (candidate);
}

}  // namespace PyZy

src/PyZyCandidates.h

deleted100644 → 0
+0 −47
Original line number Diff line number Diff line
/* vim:set et ts=4 sts=4:
 *
 * libpyzy - The Chinese PinYin and Bopomofo conversion library.
 *
 * Copyright (c) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of the
 * License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */
#ifndef __PYZY_CANDIDATES_H_
#define __PYZY_CANDIDATES_H_

#include "PyZyInputContext.h"

#include <string>
#include <vector>

namespace PyZy {

class ConcreteCandidates : public Candidates {
public:
  virtual ~ConcreteCandidates();
    virtual const Candidate & get (size_t index) const;
    virtual const size_t size () const;
    virtual void clear ();
    virtual void push_back (const Candidate &candidate);

private:
    std::vector<Candidate> m_candidates;
    size_t m_size;
};

}  // namespace PyZy

#endif  // __PYZY_CANDIDATES_H_
Loading