in CBLMisc.m
id CBLKeyForPrefixMatch(id key, unsigned depth)
969786
public static Object keyForPrefixMatch(Object key, int depth) {
        if (depth < 1)
            return key;
        if (key instanceof String) {
            return (key + "\uFFFF");
        } else if (key instanceof List) {
            ArrayList<Map<String, Object>> nuKey = new ArrayList<Map<String, Object>>((List<Map<String, Object>>) key);
            if (depth == 1) {
                nuKey.add(new HashMap<String, Object>());
            } else {
                Object lastObject = nuKey.get(nuKey.size() - 1);
                lastObject = keyForPrefixMatch(lastObject, depth - 1);
                nuKey.set(nuKey.size() - 1, (Map<String, Object>) lastObject);
            }
            return nuKey;
        } else {
            return key;
        }
    }
1193779
def solidityKeccak(cls, abi_types, values):
        
        if len(abi_types) != len(values):
            raise ValueError(
                "Length mismatch between provided abi types and values.  Got "
                "{0} types and {1} values.".format(len(abi_types), len(values))
            )

        if isinstance(cls, type):
            w3 = None
        else:
            w3 = cls
        normalized_values = map_abi_data([abi_ens_resolver(w3)], abi_types, values)

        hex_string = add_0x_prefix(''.join(
            remove_0x_prefix(hex_encode_abi_type(abi_type, value))
            for abi_type, value
            in zip(abi_types, normalized_values)
        ))
        return cls.keccak(hexstr=hex_string)
903510
@SuppressWarnings("RedundantIfStatement")
  @RestrictTo(RestrictTo.Scope.LIBRARY)
  public boolean matches(String key, int depth) {
    if (isContainer(key)) {
      // This is an artificial layer we programatically create.
      return true;
    }
    if (depth >= keys.size()) {
      return false;
    }
    if (keys.get(depth).equals(key) ||
        keys.get(depth).equals("**") ||
        keys.get(depth).equals("*")) {
      return true;
    }
    return false;
  }
780806
function passId (trace, i, j) {
	let id = (trace.id != null ? trace.id : trace)
	let n = i
	let m = j
	let key = id << 16 | (n & 0xff) << 8 | m & 0xff

	return key
}
801840
private String getFNSignatureFromIContext(INode node) {

        String ret = node.getNodeData().getName();
        List<INode> children = node.getChildrenList();
        if (children != null && children.size() > 0) {
            ret += "(";
            for (INode aChildren : children) {
                ret += getFNSignatureFromIContext(aChildren) + ",";
            }

            ret = ret.substring(0, ret.length() - 1);
            ret += ")";
        }
        return ret;

    }
4933
private int matchTail(int base, int index, String key) {
        int positionInTailArr = base - TAIL_OFFSET;

        int keyLength = key.length();
        for (int i = 0; i < keyLength; i++) {
            if (key.charAt(i) != tailBuffer.get(positionInTailArr + i)) {
                return -1;
            }
        }
        return tailBuffer.get(positionInTailArr + keyLength) == TERMINATING_CHARACTER ? index : 0;
    }
783037
private static int unsignedBinarySearch(int[] a, int fromIndex, int toIndex, int key,
      Comparator<? super Integer> c) {
    int low = fromIndex;
    int high = toIndex - 1;

    while (low <= high) {
      int mid = (low + high) >>> 1;
      int midVal = a[mid];
      int cmp = c.compare(midVal, key);
      if (cmp < 0) {
        low = mid + 1;
      } else if (cmp > 0) {
        high = mid - 1;
      } else {
        return mid; // key found
      }
    }
    return -(low + 1); // key not found.
  }
1083226
function getPrevKeyWith( keys, fullSid, ndx ) {

		ndx = ndx >= 0 ? ndx : ndx + keys.length;

		for ( ; ndx >= 0; ndx -- ) {

			var key = keys[ ndx ];

			if ( key.hasTarget( fullSid ) ) {

				return key;

			}

		}

		return null;

	}
257961
function getNextKeyWith( keys, fullSid, ndx ) {

		for ( ; ndx < keys.length; ndx ++ ) {

			var key = keys[ ndx ];

			if ( key.hasTarget( fullSid ) ) {

				return key;

			}

		}

		return null;

	}
411160
private static boolean _match (@Nonnull final byte [] aSrcBytes,
                                 @Nonnegative final int nSrcOffset,
                                 @Nonnull final byte [] aCmpBytes)
  {
    final int nEnd = aCmpBytes.length;
    for (int i = 0; i < nEnd; ++i)
      if (aSrcBytes[nSrcOffset + i] != aCmpBytes[i])
        return false;
    return true;
  }
621096
function expandMatchArr(deep) {
    var a = [];
    var line = [];
    debuglog(function () { return JSON.stringify(deep); });
    deep.forEach(function (uBreakDownLine, iIndex) {
        line[iIndex] = [];
        uBreakDownLine.forEach(function (aWordGroup, wgIndex) {
            line[iIndex][wgIndex] = [];
            aWordGroup.forEach(function (oWordVariant, iWVIndex) {
                line[iIndex][wgIndex][iWVIndex] = oWordVariant;
            });
        });
    });
    debuglog(debuglog.enabled ? JSON.stringify(line) : '-');
    var res = [];
    var nvecs = [];
    for (var i = 0; i < line.length; ++i) {
        var vecs = [[]];
        var nvecs = [];
        var rvec = [];
        for (var k = 0; k < line[i].length; ++k) {
            //vecs is the vector of all so far seen variants up to k wgs.
            var nextBase = [];
            for (var l = 0; l < line[i][k].length; ++l) {
                //debuglog("vecs now" + JSON.stringify(vecs));
                nvecs = []; //vecs.slice(); // copy the vec[i] base vector;
                //debuglog("vecs copied now" + JSON.stringify(nvecs));
                for (var u = 0; u < vecs.length; ++u) {
                    nvecs[u] = vecs[u].slice(); //
                    nvecs[u] = copyVecMembers(nvecs[u]);
                    // debuglog("copied vecs["+ u+"]" + JSON.stringify(vecs[u]));
                    nvecs[u].push(clone(line[i][k][l])); // push the lth variant
                    // debuglog("now nvecs " + nvecs.length + " " + JSON.stringify(nvecs));
                }
                //   debuglog(" at     " + k + ":" + l + " nextbase >" + JSON.stringify(nextBase))
                //   debuglog(" append " + k + ":" + l + " nvecs    >" + JSON.stringify(nvecs))
                nextBase = nextBase.concat(nvecs);
                //   debuglog("  result " + k + ":" + l + " nvecs    >" + JSON.stringify(nextBase))
            } //constru
            //  debuglog("now at " + k + ":" + l + " >" + JSON.stringify(nextBase))
            vecs = nextBase;
        }
        debuglogV(debuglogV.enabled ? ("APPENDING TO RES" + i + ":" + l + " >" + JSON.stringify(nextBase)) : '-');
        res = res.concat(vecs);
    }
    return res;
}
1232411
private static String initFindEntitiesQuery(EntityKeyMetadata entityKeyMetadata, boolean includeEmbedded) {
		StringBuilder queryBuilder = new StringBuilder( "MATCH " );
		queryBuilder.append( "(" );
		queryBuilder.append( ENTITY_ALIAS );
		queryBuilder.append( ":" );
		queryBuilder.append( ENTITY );
		queryBuilder.append( ":" );
		appendLabel( entityKeyMetadata, queryBuilder );
		queryBuilder.append( ")" );
		appendOptionalMatchOwnerEmbeddedNodes( queryBuilder );
		appendGetEmbeddedNodesIfNeeded( includeEmbedded, queryBuilder );
		return queryBuilder.toString();
	}
226097
private boolean match(final ByteBuffer buf) throws IOException {
		boolean matches = true;
		switch (getType()) {
		case MagicMimeEntry.STRING_TYPE: {
			matches = matchString(buf);
			break;
		}

		case MagicMimeEntry.SHORT_TYPE: {
			matches = matchShort(buf, ByteOrder.BIG_ENDIAN, false, (short) 0xFF);
			break;
		}

		case MagicMimeEntry.LESHORT_TYPE:
		case MagicMimeEntry.BESHORT_TYPE: {
			ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
			if (getType() == MagicMimeEntry.LESHORT_TYPE) {
				byteOrder = ByteOrder.LITTLE_ENDIAN;
			}
			boolean needMask = false;
			short sMask = 0xFF;
			final int indx = this.typeStr.indexOf('&');
			if (indx >= 0) {
				sMask = (short) Integer.parseInt(this.typeStr.substring(indx + 3), 16);
				needMask = true;
			} else if (getContent().startsWith("&")) {
				sMask = (short) Integer.parseInt(getContent().substring(3), 16);
				needMask = true;
			}
			matches = matchShort(buf, byteOrder, needMask, sMask);
			break;
		}

		case MagicMimeEntry.LELONG_TYPE:
		case MagicMimeEntry.BELONG_TYPE: {
			ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
			if (getType() == MagicMimeEntry.LELONG_TYPE) {
				byteOrder = ByteOrder.LITTLE_ENDIAN;
			}
			boolean needMask = false;
			long lMask = 0xFFFFFFFF;
			final int indx = this.typeStr.indexOf('&');
			if (indx >= 0) {
				lMask = Long.parseLong(this.typeStr.substring(indx + 3), 16);
				needMask = true;
			} else if (getContent().startsWith("&")) {
				lMask = Long.parseLong(getContent().substring(3), 16);
				needMask = true;
			}
			matches = matchLong(buf, byteOrder, needMask, lMask);
			break;
		}

		case MagicMimeEntry.BYTE_TYPE: {
			matches = matchByte(buf);
		}

		default: {
			matches = false;
			break;
		}
		}
		return matches;
	}
1049072
PartialMatch newPartialMatch(char[] key, PartialMatch pm) {
    if (tc.isEntryEnabled())
      tc.entry(this,cclass, "newPartialMatch", "key: "+new String(key)+", pm:"+pm);
    PartialMatch ans = new PartialMatch(key, pm, owner);
    if (tc.isEntryEnabled())
      tc.exit(this,cclass, "newPartialMatch", ans);
    return ans;
  }
321164
private ContentData matchBytes(byte[] bytes, int prevOffset, int level, ContentData contentData) {
		int offset = this.offset;
		if (offsetInfo != null) {
			// offset can be null if we run out of bytes
			Integer maybeOffset = offsetInfo.getOffset(bytes);
			if (maybeOffset == null) {
				return null;
			}
			offset = maybeOffset;
		}
		if (addOffset) {
			offset = prevOffset + offset;
		}
		boolean required = (testValue == null && formatter != null);
		Object val = matcher.extractValueFromBytes(offset, bytes, required);
		if (val == null) {
			return null;
		}
		if (testValue != null) {
			MutableOffset mutableOffset = new MutableOffset(offset);
			val = matcher.isMatch(testValue, andValue, unsignedType, val, mutableOffset, bytes);
			if (val == null) {
				return null;
			}
			offset = mutableOffset.offset;
		}

		if (contentData == null) {
			contentData = new ContentData(name, mimeType, level);
			// default is a child didn't match, set a partial so the matcher will keep looking
			contentData.partial = true;
		}
		if (formatter != null) {
			if (clearFormat) {
				contentData.sb.setLength(0);
			}
			// if we are appending and need a space then prepend one
			if (formatSpacePrefix && contentData.sb.length() > 0) {
				contentData.sb.append(' ');
			}
			matcher.renderValue(contentData.sb, val, formatter);
		}
		logger.trace("matched data: {}: {}", this, contentData);

		if (children == null) {
			// no children so we have a full match and can set partial to false
			contentData.partial = false;
		} else {
			// run through the children to add more content-type details
			boolean allOptional = true;
			for (MagicEntry entry : children) {
				if (!entry.isOptional()) {
					allOptional = false;
				}
				// goes recursive here
				entry.matchBytes(bytes, offset, level + 1, contentData);
				// we continue to match to see if we can add additional children info to the name
			}
			if (allOptional) {
				contentData.partial = false;
			}
		}

		/*
		 * Now that we have processed this entry (either with or without children), see if we still need to annotate the
		 * content information.
		 * 
		 * NOTE: the children will have the first opportunity to set this which makes sense since they are the most
		 * specific.
		 */
		if (name != MagicEntryParser.UNKNOWN_NAME && contentData.name == MagicEntryParser.UNKNOWN_NAME) {
			contentData.name = name;
		}
		/*
		 * Set the mime-type if it is not set already or if we've gotten more specific in the processing of a pattern
		 * and determine that it's actually a different type so we can override the previous mime-type. Example of this
		 * is Adobe Illustrator which looks like a PDF but has extra stuff in it.
		 */
		if (mimeType != null && (contentData.mimeType == null || level > contentData.mimeTypeLevel)) {
			contentData.mimeType = mimeType;
			contentData.mimeTypeLevel = level;
		}
		return contentData;
	}
268736
private static ResourceBundle findMatch(String basename, Locale pref) {

        ResourceBundle match = null;
        try {
            ResourceBundle bundle = CmsResourceBundleLoader.getBundle(basename, pref);
            match = bundle;
        } catch (MissingResourceException mre) {
            // ignored
        }
        return match;
    }
639202
private String ubPrefixFeatureString(String feat)
  {
    if (feat.endsWith("|C")) {
      return "U-" + feat;
    } else if (feat.endsWith("|CpC")) {
      return "B-" + feat;
    } else {
      return feat;
    }
  }