mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
change to using once_cell for lazy init
This commit is contained in:
@@ -22,7 +22,7 @@ use std::{collections::HashMap, rc::Rc};
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
use lazy_static::lazy_static;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use crate::{
|
||||
common::{
|
||||
@@ -34,10 +34,12 @@ use crate::{
|
||||
|
||||
use super::{decoded_bit_stream_parser, BitMatrixParser, DataBlock, QRCodeDecoderMetaData};
|
||||
|
||||
lazy_static! {
|
||||
//rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256);
|
||||
static ref RS_DECODER : ReedSolomonDecoder = ReedSolomonDecoder::new(get_predefined_genericgf(PredefinedGenericGF::QrCodeField256));
|
||||
}
|
||||
//rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256);
|
||||
static RS_DECODER: Lazy<ReedSolomonDecoder> = Lazy::new(|| {
|
||||
ReedSolomonDecoder::new(get_predefined_genericgf(
|
||||
PredefinedGenericGF::QrCodeField256,
|
||||
))
|
||||
});
|
||||
|
||||
pub fn decode_bool_array(image: &Vec<Vec<bool>>) -> Result<DecoderRXingResult, Exceptions> {
|
||||
decode_bool_array_with_hints(image, &HashMap::new())
|
||||
|
||||
@@ -20,13 +20,11 @@ use crate::{common::BitMatrix, Exceptions};
|
||||
|
||||
use super::{ErrorCorrectionLevel, FormatInformation};
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
pub type VersionRef = &'static Version;
|
||||
|
||||
lazy_static! {
|
||||
static ref VERSIONS: Vec<Version> = Version::buildVersions();
|
||||
}
|
||||
static VERSIONS: Lazy<Vec<Version>> = Lazy::new(|| Version::buildVersions());
|
||||
|
||||
/**
|
||||
* See ISO 18004:2006 Annex D.
|
||||
|
||||
@@ -25,14 +25,12 @@ use crate::{
|
||||
EncodeHintType, EncodeHintValue,
|
||||
};
|
||||
use encoding::EncodingRef;
|
||||
use lazy_static::lazy_static;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use super::QRCode;
|
||||
|
||||
lazy_static! {
|
||||
static ref SHIFT_JIS_CHARSET: EncodingRef =
|
||||
encoding::label::encoding_from_whatwg_label("SJIS").unwrap();
|
||||
}
|
||||
static SHIFT_JIS_CHARSET: Lazy<EncodingRef> =
|
||||
Lazy::new(|| encoding::label::encoding_from_whatwg_label("SJIS").unwrap());
|
||||
|
||||
/**
|
||||
* @author satorux@google.com (Satoru Takabayashi) - creator
|
||||
|
||||
@@ -21,7 +21,7 @@ use std::collections::HashMap;
|
||||
|
||||
use encoding::EncodingRef;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use once_cell::sync::Lazy;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use crate::{
|
||||
@@ -35,10 +35,8 @@ use crate::{
|
||||
|
||||
use super::{mask_util, matrix_util, BlockPair, ByteMatrix, MinimalEncoder, QRCode};
|
||||
|
||||
lazy_static! {
|
||||
static ref SHIFT_JIS_CHARSET: EncodingRef =
|
||||
encoding::label::encoding_from_whatwg_label("SJIS").unwrap();
|
||||
}
|
||||
static SHIFT_JIS_CHARSET: Lazy<EncodingRef> =
|
||||
Lazy::new(|| encoding::label::encoding_from_whatwg_label("SJIS").unwrap());
|
||||
|
||||
// The original table is defined in the table 5 of JISX0510:2004 (p.19).
|
||||
const ALPHANUMERIC_TABLE: [i8; 96] = [
|
||||
|
||||
Reference in New Issue
Block a user